Windows App - C++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • August1

    #1

    Windows App - C++

    Hi,

    I'm beginning to approach Windows programming in C++. I've written
    a short
    application which is to do nothing more than demonstrate the Window
    style being used. The child windows are not appearing within the
    parent window. Could someone point out the cause?

    Thank you in advance,
    Anthony

    #include <windows.h>
    #include <string.h>

    long WINAPI MainWndProc(HWN D,UINT,WPARAM,L PARAM);

    HWND hWnd;
    HWND hwndEdit;
    HWND hwndButton;
    HWND hwndClearButton ;
    char szMessage[50] = "";

    int WINAPI WinMain(HINSTAN CE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
    {
    WNDCLASS wc;
    wc.lpszClassNam e = "Style1";
    wc.lpfnWndProc = MainWndProc;
    wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(NULL,I DI_APPLICATION) ;
    wc.hCursor = LoadCursor(NULL ,IDC_ARROW);
    wc.hbrBackgroun d = (HBRUSH)( COLOR_WINDOW+1 );
    wc.lpszMenuName = "";
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    RegisterClass(& wc);

    hWnd = CreateWindow("S tyle1","Border Demonstration",
    WS_OVERLAPPEDWI NDOW,CW_USEDEFA ULT,CW_USEDEFAU LT,
    185,265,NULL,NU LL,hInstance,NU LL);

    hwndEdit = CreateWindow("E DIT",NULL,
    WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT,
    10,10,155,20,hW nd,NULL,hInstan ce,NULL);

    hwndButton = CreateWindow("B UTTON","Message ",
    WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTO N,
    10,40,35,35,hWn d,NULL,hInstanc e,NULL);

    hwndClearButton = CreateWindow("B UTTON","Clear",
    WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTO N,
    50,40,35,35,hWn d,NULL,hInstanc e,NULL);


    ShowWindow(hWnd ,nCmdShow);

    MSG msg;
    while(GetMessag e(&msg,NULL,0,0 ))
    {
    TranslateMessag e(&msg);
    DispatchMessage (&msg);
    }
    return msg.wParam;
    }//end WinMain()

    long WINAPI MainWndProc(HWN D hWnd,UINT msg,WPARAM wParam,LPARAM
    lParam)
    {
    HWND hwndCtl = (HWND)lParam;
    switch(msg)
    {
    case WM_COMMAND:
    switch(wParam)
    {
    case BN_CLICKED:
    if(hwndCtl == hwndButton)
    {
    strcpy(szMessag e,"This program is an overlapped style Window.");
    SetWindowText(h wndEdit,szMessa ge);
    }
    else if(hwndCtl == hwndClearButton )
    {
    strcpy(szMessag e,"");
    SetWindowText(h wndEdit,szMessa ge);
    }
    }
    break;
    case WM_DESTROY:
    PostQuitMessage (0);
    return 0;
    default:
    return DefWindowProc(h Wnd,msg,wParam, lParam);
    }

    return 0;
    }//end MainWndProc()
  • Victor Bazarov

    #2
    Re: Windows App - C++

    August1 wrote:[color=blue]
    > I'm beginning to approach Windows programming in C++. I've written
    > a short
    > application which is to do nothing more than demonstrate the Window
    > style being used. The child windows are not appearing within the
    > parent window. Could someone point out the cause? [...][/color]

    Somebody in a newsgroup dedicated to Windows programming undoubtedly
    could. Here your question is off-topic. Please consider choosing
    the newsgroup where to post more carefully.

    V

    Comment

    • August1

      #3
      Re: Windows App - C++

      > Somebody in a newsgroup dedicated to Windows programming undoubtedly[color=blue]
      > could. Here your question is off-topic. Please consider choosing
      > the newsgroup where to post more carefully.[/color]

      The Windows API is mainly written in C. Windows applications can be
      written in any number of source languages which then make calls to
      your system's API - languages as VB, C++, J++, Foxpro, etc. Using C++
      you may also use the Microsoft Foundation Classes to facilitate
      communication with the API and program execution, though not
      recommended for cross-platform functionality. The language I am
      referencing is C++. The question is not off-topic. I have already
      resolved the matter, but if you have nothing pertaining to code
      assessment - I have no interest in your suggestion.

      Regards

      Comment

      • John Harrison

        #4
        Re: Windows App - C++


        "August1" <anthonyb_nc@ho tmail.com> wrote in message
        news:fce2a102.0 410182213.170fe 486@posting.goo gle.com...[color=blue][color=green]
        >> Somebody in a newsgroup dedicated to Windows programming undoubtedly
        >> could. Here your question is off-topic. Please consider choosing
        >> the newsgroup where to post more carefully.[/color]
        >
        > The Windows API is mainly written in C. Windows applications can be
        > written in any number of source languages which then make calls to
        > your system's API - languages as VB, C++, J++, Foxpro, etc. Using C++
        > you may also use the Microsoft Foundation Classes to facilitate
        > communication with the API and program execution, though not
        > recommended for cross-platform functionality. The language I am
        > referencing is C++. The question is not off-topic.[/color]

        It is. If you want answers instead of abuse try

        news:comp.os.ms-windows.program mer.win32

        But if you just want to waste your time, post here!

        john


        Comment

        • JKop

          #5
          Re: Windows App - C++

          [color=blue]
          > The Windows API is mainly written in C. Windows applications can be
          > written in any number of source languages which then make calls to
          > your system's API - languages as VB, C++, J++, Foxpro, etc. Using C++
          > you may also use the Microsoft Foundation Classes to facilitate
          > communication with the API and program execution, though not
          > recommended for cross-platform functionality. The language I am
          > referencing is C++. The question is not off-topic. I have already
          > resolved the matter, but if you have nothing pertaining to code
          > assessment - I have no interest in your suggestion.[/color]


          You misunderstand.

          You'll hear no mention whatsoever of *any* platform here! We converse here
          about what can actually be done with C++ itself and its Standard Libraries.


          -JKop

          Comment

          • Randy Yates

            #6
            Re: Windows App - C++

            anthonyb_nc@hot mail.com (August1) writes:
            [color=blue][color=green]
            >> Somebody in a newsgroup dedicated to Windows programming undoubtedly
            >> could. Here your question is off-topic. Please consider choosing
            >> the newsgroup where to post more carefully.[/color]
            >
            > The Windows API is mainly written in C. Windows applications can be
            > written in any number of source languages which then make calls to
            > your system's API - languages as VB, C++, J++, Foxpro, etc. Using C++
            > you may also use the Microsoft Foundation Classes to facilitate
            > communication with the API and program execution, though not
            > recommended for cross-platform functionality.[/color]

            All true. Irrelevent, but true.
            [color=blue]
            > The language I am referencing is C++. The question is not off-topic.[/color]

            Oh but it is, just as asking an English teacher for help on your
            microbiology homework probably won't be productive even though the
            assignment is written in English.
            --
            % Randy Yates % "...the answer lies within your soul
            %% Fuquay-Varina, NC % 'cause no one knows which side
            %%% 919-577-9882 % the coin will fall."
            %%%% <yates@ieee.org > % 'Big Wheels', *Out of the Blue*, ELO

            Comment

            • JKop

              #7
              Re: Windows App - C++

              Mike Wahler posted:
              [color=blue]
              > "August1" <anthonyb_nc@ho tmail.com> wrote in message
              > news:fce2a102.0 410190955.7da5d 2ae@posting.goo gle.com...[color=green]
              >> "> But if you just want to waste your time, post here![color=darkred]
              >> >
              >> > john[/color]
              >>
              >> Depends on your perceptions. Next.[/color]
              >
              > If you're expecting answers to Windows programming
              > questions here, be warned that you'll be waiting
              > a long time. The choice is yours.
              >
              > -Mike[/color]


              Not that long really. Here's an answer:


              Fuck Off


              -JKop

              Comment

              • August1

                #8
                Re: Windows App - C++

                > All true. Irrelevent, but true.[color=blue]
                >
                > Oh but it is, just as asking an English teacher for help on your
                > microbiology homework probably won't be productive even though the
                > assignment is written in English.[/color]

                Irrelevent only to those who find it irrelevent, or dedicate much of
                their time in C/C++ with console applications. Many people today
                prefer to use C++ for Windows apps, so they have a greater
                understanding of the language and use it for more than console
                applications. Therefore they wouldn't find it difficult to answer
                console-related or gui-related questions should any be presented.

                Regards

                Comment

                • JKop

                  #9
                  Re: Windows App - C++

                  August1 posted:
                  [color=blue][color=green]
                  >> All true. Irrelevent, but true.
                  >>
                  >> Oh but it is, just as asking an English teacher for help on your
                  >> microbiology homework probably won't be productive even though the
                  >> assignment is written in English.[/color]
                  >
                  > Irrelevent only to those who find it irrelevent, or dedicate much of
                  > their time in C/C++ with console applications.[/color]

                  Not really. I make Win32 Graphical User Interface programs, but I still find
                  all this irrelevant considering where we are.
                  [color=blue]
                  > Many people today
                  > prefer to use C++ for Windows apps, so they have a greater
                  > understanding of the language and use it for more than console
                  > applications.[/color]

                  Bullshit.

                  If anything, coding for Windows will just mess up your C++ technique.

                  Case and point:

                  #define LRESULT long

                  [color=blue]
                  > Therefore they wouldn't find it difficult to answer
                  > console-related or gui-related questions should any be presented.[/color]


                  Absolutely correct.

                  Where are we again?



                  -JKop

                  Comment

                  • Mike Wahler

                    #10
                    Re: Windows App - C++

                    "August1" <anthonyb_nc@ho tmail.com> wrote in message
                    news:fce2a102.0 410191014.d4d1e 2a@posting.goog le.com...[color=blue][color=green]
                    > > All true. Irrelevent, but true.
                    > >
                    > > Oh but it is, just as asking an English teacher for help on your
                    > > microbiology homework probably won't be productive even though the
                    > > assignment is written in English.[/color]
                    >
                    > Irrelevent only to those who find it irrelevent, or dedicate much of
                    > their time in C/C++ with console applications. Many people today
                    > prefer to use C++ for Windows apps, so they have a greater
                    > understanding of the language and use it for more than console
                    > applications. Therefore they wouldn't find it difficult to answer
                    > console-related or gui-related questions should any be presented.[/color]

                    You're missing the point again. I'm fairly certain that
                    many people participating here have good or even expert
                    knowledge of e.g. GUI programming. They'd not find it
                    difficult at all to answer questions about it. But they
                    still don't do it here. Guess why.

                    John has already given you the name of the group where
                    your Windows questions will be welcomed with open arms.
                    If you go there, you'll even see his name, and articles
                    by him discussing Windows. But I now wonder if he'll
                    help you even there, given your behavior here.

                    Here is the "official" document defining the purpose
                    of comp.lang.c++:



                    Please read it carefully before posting here again. Thank you.

                    -Mike


                    Comment

                    • John Harrison

                      #11
                      Re: Windows App - C++


                      "August1" <anthonyb_nc@ho tmail.com> wrote in message
                      news:fce2a102.0 410190955.7da5d 2ae@posting.goo gle.com...[color=blue]
                      >"> But if you just want to waste your time, post here![color=green]
                      >>
                      >> john[/color]
                      >
                      > Depends on your perceptions. Next.
                      >[/color]

                      Next? Am I being insulted?

                      John


                      Comment

                      • Victor Bazarov

                        #12
                        Re: Windows App - C++

                        John Harrison wrote:[color=blue]
                        > "August1" <anthonyb_nc@ho tmail.com> wrote in message
                        > news:fce2a102.0 410190955.7da5d 2ae@posting.goo gle.com...
                        >[color=green]
                        >>"> But if you just want to waste your time, post here!
                        >>[color=darkred]
                        >>>john[/color]
                        >>
                        >>Depends on your perceptions. Next.
                        >>[/color]
                        >
                        >
                        > Next? Am I being insulted?[/color]

                        Do you feel insulted? Nobody can tell except you. :-)

                        Comment

                        • Victor Bazarov

                          #13
                          Re: Windows App - C++

                          Mike Wahler wrote:[color=blue]
                          > [...]
                          > Here is the "official" document defining the purpose
                          > of comp.lang.c++:
                          >
                          > http://www.slack.net/~shiva/welcome.txt
                          >
                          > Please read it carefully before posting here again. Thank you.[/color]

                          Mike, I wish I had your patience. I hope you're not really
                          holding your breath that 'August1' will read the welcome msg.
                          I'd really be disappointed if you suffocate.

                          Comment

                          • Randy Yates

                            #14
                            Re: Windows App - C++

                            anthonyb_nc@hot mail.com (August1) writes:
                            [color=blue][color=green]
                            > > All true. Irrelevent, but true.
                            > >
                            > > Oh but it is, just as asking an English teacher for help on your
                            > > microbiology homework probably won't be productive even though the
                            > > assignment is written in English.[/color]
                            >
                            > Irrelevent only to those who find it irrelevent, or dedicate much of
                            > their time in C/C++ with console applications. Many people today
                            > prefer to use C++ for Windows apps, so they have a greater
                            > understanding of the language and use it for more than console
                            > applications. Therefore they wouldn't find it difficult to answer
                            > console-related or gui-related questions should any be presented.[/color]

                            Oh dear. I'm afraid I've thrown pearls before swine. I'm not sure
                            what number would be less, your IQ or number of years in school.
                            --
                            Randy Yates
                            Sony Ericsson Mobile Communications
                            Research Triangle Park, NC, USA
                            randy.yates@son yericsson.com, 919-472-1124

                            Comment

                            • Mike Wahler

                              #15
                              Re: Windows App - C++

                              "Victor Bazarov" <v.Abazarov@com Acast.net> wrote in message
                              news:GDddd.5945 $Ae.5805@newsre ad1.dllstx09.us .to.verio.net.. .[color=blue]
                              > Mike Wahler wrote:[color=green]
                              > > [...]
                              > > Here is the "official" document defining the purpose
                              > > of comp.lang.c++:
                              > >
                              > > http://www.slack.net/~shiva/welcome.txt
                              > >
                              > > Please read it carefully before posting here again. Thank you.[/color]
                              >
                              > Mike, I wish I had your patience.[/color]

                              It comes and goes. :-)
                              [color=blue]
                              > I hope you're not really
                              > holding your breath that 'August1' will read the welcome msg.[/color]

                              Not really, but I decided I'd give him one last chance.
                              Nobody had posted that link in this thread yet. We'll see.
                              But I have indeed been glancing at my plonk button.
                              [color=blue]
                              > I'd really be disappointed if you suffocate.[/color]

                              Thanks for caring about me. :-)

                              -Mike


                              Comment

                              Working...