Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


get me the logic of this code pls !!!!!!!!!!!!!

hello friends , i am new to api programming , i am trying to do a notepad program.
in that prog . i creates the parent window using thw api -
hparentwindow = CreateWindowEx(.................);
i am using this to get the parent window. Only when i use ShowWindow()
api i can see the window.during WM_CREATE message processing i have created a child window of type EDIT using the same
function hedit = CreateWindow(..."EDIT"................); i can see the edit class window with out calling ShowWindow api , how is this Possible. pls reply thanks


  • edocecrousedocecrous Posts: 49
    First of all, did you use WS_VISIBLE flag in the dwStyle field? If you did, the window should be visible after creation.
    If you did, but also in the callback routine you specified your own messagehandler functions, make sure if you have no routine for something, pass the hwnd,msg,wparam,lparam to the default windows message handler. If you don't, your window will be not drawn, because the default handler is responsible to do that.

    Also, this could help, so I tell you, what happens, when you start up your program /any program/:
    (the numbers represent the sequence, the stuff starting with a long space represents the callback routine)

    1 Definitions,Includes,Globals
    2 WinMain function starts
    3 winclass,RegisterClass,CreateWindow
    4 WinProc - MsgHandler starts up
    5 WM_CREATE executes (get called)
    6 WM_ERASEBKGND executes (get called)
    7 Main Loop (runs 1 cycle)
    8 WM_PAINT (get called)
    9 Main Loop (runs til exit)
    10 WM_CLOSE (get called)
    11 WM_DESTROY (get called)
    12 End WinMain, return to windows

    And your main loop should look like this:
    if (PeekMessage(&msg,NULL,...
    if (msg.message == WM_QUIT) ...
    if (msg.message == WM_KEYDOWN) ...
    }// end of peekmessage
    }//end of while

    Of course, you can use a case seq. instead of the if-s, but my routine used an extensive case seq. to handle the WM_KEYDOWN message, and embeding case sequences are not a good idea...

    Good luck with your program, and don't forget, you can always use breakpoints to find out what your code actually does. :-)
    /it's not walid for DirectX of course.../

    (system/game programmer)

Sign In or Register to comment.