bug

This is a discussion on bug within the Windows Programming forums, part of the Platform Specific Boards category; well you might remember me asking about this here before, I figured out a way to get it done without ...

  1. #1
    Madly in anger with you
    Join Date
    Nov 2005
    Posts
    211

    bug

    well you might remember me asking about this here before, I figured out a way to get it done without getting any abnormal looking listview control (it got resized, but there parts of edge lines left from its old alignment, its hard to explain but it was just really weird).

    Ken Fitlike suggested just sending the WM_SIZE message to hwndStatBar, however when I tried that I got one of those listview control abnormalities. I've attached a screenshot, since they are so hard to explain, you'll notice the blue line on the right side of the listview. that will appear when I:

    1. Execute the program, the dialog opens up in its default size.
    2. I minimize the dialog.
    3. I click the dialog in the task bar (to restore it).
    4. I maximize the dialog.

    using Ken's idea, which is a bug in my eyes. my remedy was my original code:

    Code:
    case WM_SIZE:
    		/* Handle maximizing/minimizing of the dialog box by appropriately resizing its controls. */
    		GetClientRect(hWnd, &rect);
    
    		MoveWindow(hwndList, rect.left, rect.top, LOWORD(lParam), HIWORD(lParam), FALSE);
    		MoveWindow(hwndStatBar, rect.left, rect.top, LOWORD(lParam), HIWORD(lParam), FALSE);
    
    		return TRUE;
    which fixed the problem of that weird line, no matter how I minimize/restore/maximize the dialog. however I was just doing some serious testing when I ran into another problem.

    you'll notice in the screenshot I've attached that you can see the status bar. that shouldn't be, when I took the screenshot I chose to select a specific window, and I could not target the listview control window without including the status bar.

    Code:
    case WM_NOTIFY:
    		/* Only handle WM_NOTIFY messages from the main listview control. */
    		if(((LPNMHDR)lParam)->hwndFrom == hwndList) {
    			switch(((LPNMHDR)lParam)->code) {
    			case NM_DBLCLK:
    			case NM_RCLICK:
                                                    /* some code to create a popup menu follows here, which is even executed if the message is coming from hwndStatBar */
    the check to make sure that the message is coming from hwndList fails when the message arrives from the status bar, execution follows through to the switch(), which should not be happening, I don't want to handle any messages from the status bar.

    this tells me that something undesired is likely happening with the way I'm handling WM_SIZE, as this will only occur after that message has been recieved (after the window has been minimized/maximized/restored). I'm guessing my call to MoveWindow() is to blame, I'd assume that somehow the listview control window is overlapping the status bar, probably as a result of wrong coordinates passed to MoveWindow().

    does anyone know how I could resolve this? I'm obviously not very good with this rect/dimensional stuff. any help here would be greatly appreciated.

    thank you in advance.
    Attached Images Attached Images  

    Intel Core 2 Quad Q6600 @ 2.40 GHz
    3072 MB PC2-5300 DDR2
    2 x 320 GB SATA (640 GB)
    NVIDIA GeForce 8400GS 256 MB PCI-E

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Try setting the last param of MoveWindow() to TRUE.

    That is, ask for the control to redraw itself once it has changed size.

    I don't think this would happen if the ctrl had any elements, as this would force a redraw of the ctrl's client area.
    "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

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    I have re-read the question and don't think I answered what you asked....

    WM_SIZE
    filter out the minimise msgs by looking at the WParam for SIZE_MINIMISED, return 0 for this msg.

    Your move window params are not 100% correct.

    MoveWindow(hwndList, rect.left, rect.top, LOWORD(lParam), HIWORD(lParam), FALSE);

    should be (although I don't see it making any difference)

    MoveWindow(hwndList, 0, 0, LOWORD(lParam), HIWORD(lParam), FALSE);

    or

    MoveWindow(hwndList, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, FALSE);

    WM_NOTIFY
    Check the value in the HWND is correct or use GetDlgItem()
    Check the controls ID (NMHDR->idFrom) rather than the HWND (this is what I do and it works).

    I then look for LVN msgs ie LVN_ITEMCHANGED in the NMHDR->code

    EDIT:
    Dohhhhhh! Realised what part of your problem is!

    You do want both these controls to cover the WHOLE client area (in rect)?

    Otherwise change the size params as you are moving both controls to cover the whole client area.

    Code:
    #define   STATUS_BAR_HEIGHT    25
    MoveWindow(hwndList, rect.left, rect.top, LOWORD(lParam), HIWORD(lParam)-STATUS_BAR_HEIGHT, FALSE);
    MoveWindow(hwndStatBar, rect.left, rect.bottom-STATUS_BAR_HEIGHT, LOWORD(lParam), HIWORD(lParam), FALSE);
    Last edited by novacain; 05-08-2007 at 04:16 AM.
    "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. gaks bug?
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-31-2008, 03:47 PM
  2. Debugging a rare / unreproducible bug..
    By g4j31a5 in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 08-05-2008, 01:56 PM
  3. ATL bug of CComPtr?
    By George2 in forum Windows Programming
    Replies: 6
    Last Post: 04-07-2008, 08:52 AM
  4. Fixing bug in Quake 2 Engine!
    By hajas in forum Game Programming
    Replies: 4
    Last Post: 06-22-2007, 11:12 AM
  5. What is year 2038 bug?
    By year2038bug in forum A Brief History of Cprogramming.com
    Replies: 67
    Last Post: 09-04-2005, 07:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21