BackGround

I have many questions,
1.Can anyone help me on this issue,i want to change my background color of client area in my window whenever i click & drag my left mouse button,i did with setbkcolor() but it's not working,why?

2.What is the use of WS_MINIMIZE?

3.I read that wparam & lparam messages sent to the windowprocedure is different for each message sent.Is it true?If means then each time what value is sent for these 2 parameters during each message?

4.What is the difference btwn WM_QUIT & WM_DESTROY,why we are using WM_DESTROY only mostly & not WM_QUIT?

Advance Thanks!!!
1. setbkcolor() is for when displaying text within a window (e.g when using the TextOut function).
You set the actual backgound colour for
a particular window class when registering the window class here:
1
2
3
4
5
6
7
8
9
10
11
WNDCLASSEX wcex = {0};

  wcex.cbSize		= sizeof(WNDCLASSEX);
  wcex.lpfnWndProc	= WndProc;
  wcex.hInstance		= hInstance;
  wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
  wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1); //<<======Here
  wcex.lpszClassName	= "MAIN";
  wcex.hIconSm		= LoadIcon(NULL,IDC_ARROW);

  RegisterClassEx(&wcex);


and/or you can set it for an individual window by intercepting the WM_ERASEBKGND and WM_PAINT messages and doing it there.


2.WS_MINIMIZE - (Windows style MINIMIZE(d) - the window will start off in the iconized state).

3. wparam & lparam messages are NOT messages.
The windows procedure parameters look something like this:
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
As you can see the actual message (such as WM_CREATE) is a unsigned integer.
The wparam amd lparam may carry extra information about the message.
For example :
For the WM_PAINT message both wparam and lparam are 0 (zero).
For the WM_CREATE message, wparam is not used, lparam is a pointer to a CREATESTRUCT

4.The usual method of closing an application goes something like this:
4a. User slects close from the main menu or clicks the X button.
4b. Windows sent WM_CLOSE message.
4c. Programmer intercepts WM_CLOSE message, confirms Close request, and calls DestroyWindow() function
(Note if programmer does not intercept the WM_CLOSE message, the default windows procedure will call DestroyWindow() function)

4d. The DestroyWindow() functions, destroys the window (what else) and sends a WM_DESTROY message.

4e. Programmer intercepts WM_DESTROY message - does any final cleanup and calls PostQuitMessage() function.
(or the default windows procedure does it for you)

4f. The PostQuitMessage() function sends a WM_QUIT message, which cause the message loop to stop processing
and the application to exit.


Last edited on
All of this is clearly explained in MSDN, in details
RTFM.
Topic archived. No new replies allowed.