Thread: Explanation!!!

  1. #1
    MITCHELL
    Guest

    Explanation!!!

    i am new in window programming. can i ask u something about this?

    what is Hwnd?
    what is Hdc HDC?

    Wparam,wm_paint,wm_char!!! that is far i asked first.
    can i have some good explanation on this?
    plss...
    ))
    why we need the HDC?

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227

    Re: Explanation!!!

    Originally posted by MITCHELL
    i am new in window programming. can i ask u something about this?

    what is Hwnd?
    what is Hdc HDC?

    Wparam,wm_paint,wm_char!!! that is far i asked first.
    can i have some good explanation on this?
    plss...
    ))
    why we need the HDC?

    Well first off to do almost anything in windows programming you need what's known as a handle to what you want to mess with.

    HWND = handle to a window
    HDC = handle to a device context

    A device context is what you need to do any painting (which includes text, etc). It specifies what region you're referring to painting on.

    WParam and LParam are different parts of messages that you can get. Windows is a message(event)-driven system. This means that when your program recieves a message from windows, your program needs to react accordingly. WM_PAINT and WM_CHAR are examples of messages you can get. In WParam or LParam might get passed coordinates or other values that the code for each message may require.

  3. #3
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    couldn't have said it better, you just missed what a handle is:

    a handle is basically a number used to access a window, a device context, or even an application.

    Oskilian

  4. #4
    Mitchell
    Guest
    hi,zen.
    i think u have given me a good explanation.
    but..what can we do with the lparam and wparam?
    i am still confious in that matter.

    pls help me out with this.Thanks.
    where can i learn more in here?
    show me the way.... ))

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    When you create an application/program it has a HINSTANCE. This is the HWND to the program.
    Each window or dialog in the program has a HWND(as do the controls on the dialog/windows).
    When Windows gets a message for your program it is passed to a special function, a CALLBACK.
    Here you write a complicated SWITCH/CASE statement to handle the different types of messages(ie WM_PAINT to redraw the screen)
    Additional information is passed with the message, WPARAM and LPARAM. Depending on what message, you determine what happened.
    for example if the user resized the window the following would be your code
    Code:
    //*******************************
    case	WM_SIZE://size message
    cxSize=(int)(LOWORD(lParam));//get the new width
    cySize=(int)(HIWORD(lParam));//get the new height
    RePaintView(hWnd,cxSize,cySize);//do the resize in your function
    break;
    //*******************************

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked Lists
    By Bleu_Cheese in forum C++ Programming
    Replies: 13
    Last Post: 12-21-2007, 09:17 PM
  2. Explanation of switch statements
    By ammochck21 in forum C++ Programming
    Replies: 6
    Last Post: 11-04-2006, 02:59 PM
  3. printf function explanation
    By vice in forum C Programming
    Replies: 3
    Last Post: 09-21-2005, 08:35 PM
  4. Explanation
    By fallonides in forum C Programming
    Replies: 3
    Last Post: 03-19-2003, 01:41 PM
  5. basic linked list declaration..need explanation
    By aspand in forum C Programming
    Replies: 3
    Last Post: 06-07-2002, 05:55 PM