Thread: a quick newbie question about messages

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    33

    a quick newbie question about messages

    in the WndProc where u check for all the different messages windows sends your program, why is it that i have made a window that cannot be resized, yet i have code that looks like this.....

    Code:
    		case WM_SIZE:
    		csizex = LOWORD(lParam);
    		csizey = HIWORD(lParam);
    		break;
    if i can't change the size, how does this message get sent to my program?

    is the WM_SIZE message sent on creation of my window? If so, how many other messages get sent to my program on creation of my window?

    Thanks for your time!

    Werdy666

  2. #2
    Unregistered
    Guest
    the wm_size msg is triggered when one trys to resize the window. the wm_create msg is triggered when the window is created. you don't seem to be understanding the msg loop properly, i would explain but i'm VERY lazy right now. but for a quick one, the msg loop handles events so when one trys to resize the window, the wm_size msg is triggered, when the window is created (upon execution) - the wm_create msg is triggered. i'm learning the win api myself and it is well gay.

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    33
    yeah i understand that WM_SIZE is only called when you try to resize the window and WM_Create is called when the window is created....

    here is my message loop...

    Code:
    switch(msg)
    
    	    {
    		case WM_SIZE:
    		csizex = LOWORD(lParam);
    		csizey = HIWORD(lParam);
    		break;
        
        
    		case WM_LBUTTONDOWN:
    		{
    		int mousex = LOWORD(lParam);
    		int mousey = HIWORD(lParam);
    		region = 0;
    		
    		if (mousex < (csizex/2) && mousey <(csizey/2))
    		region = 1;
    		
    		if (mousex > (csizex/2) && mousey <(csizey/2))
    		region = 2;		
    		
    		if (mousex < (csizex/2) && mousey >(csizey/2))
    		region = 3;
    		
    		if (mousex > (csizex/2) && mousey >(csizey/2))
    		region = 4;
    		
    		if (region>0) sprintf(regionbuff,"You clicked in Region %i",region);
    		else sprintf(regionbuff,"You clicked on a line!!!");
    		MessageBox(hwnd,regionbuff,"Region clicked...",MB_OK);
    		}
    		break;
    		
            case WM_CLOSE:
                DestroyWindow(hwnd);
            break;
            case WM_DESTROY:
                PostQuitMessage(0);
            break;
    
            case WM_PAINT:
    		// vertical line        
    		hdc = BeginPaint (hwnd, &ps) ;
            MoveToEx (hdc, (csizex/2), 0, NULL) ;
    		LineTo   (hdc, (csizex/2), csizey ) ;
    		// horizontal line
            MoveToEx (hdc, 0, (csizey/2), NULL) ;
    		LineTo   (hdc, (csizex), (csizey/2) ) ;
    
            default:
                return DefWindowProc(hwnd, msg, wParam, lParam);
        }
    Now if my window has no resize button, how is it that csizex and csizey have values in them from wm_size? my understanding is that WM_SIZE will never be called in my program and therefore should have errors when the mouse button is clicked.

    Basically this program draws to lines to divide the screen into 4 parts and then i detect which part is clicked in.

    And another quick question, if i make a window 800x600 then that is the size of the whole window and not just the client area of the window right?

    Thanks for your time

    Werdy666

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>is the WM_SIZE message sent on creation of my window?

    Yes, AFAIK

    >>And another quick question, if i make a window 800x600 then that is the size of the whole window and not just the client area of the window right?

    Yes, use GetWindowRect() to test (is in screen coods)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick question about types...
    By Elysia in forum C++ Programming
    Replies: 32
    Last Post: 12-07-2008, 05:39 AM
  2. Newbie question
    By geomark in forum C Programming
    Replies: 11
    Last Post: 05-17-2004, 10:08 PM
  3. C++ newbie / linux not so newbie question
    By goldmonkey in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2003, 12:27 PM
  4. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM