Button positioning

This is a discussion on Button positioning within the Windows Programming forums, part of the Platform Specific Boards category; You've also tried novocain's idea? Code: ShowWindow(hwnd,SW_SHOWMAXIMIZED);...

  1. #46
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    You've also tried novocain's idea?

    Code:
    ShowWindow(hwnd,SW_SHOWMAXIMIZED);

  2. #47
    Registered User
    Join Date
    May 2005
    Posts
    207
    You mean put that in WM_CREATE? I used WS_MAXIMIZE instead of SW_SHOWMAXIMIZED (I thought it was a typo).

    I went back and changed it to SW_SHOWMAXIMIZED and it had a curious effect: it maximized horizontally but not vertically.

    I'm just going to start over. I always backup my programs before I start making changes. Looks like a good practice when dealing with Microsux.

    mw
    Blucast Corporation

  3. #48
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    The strange thing is, in the previous code you posted (the long one), I couldn't get it to compile without fixing alot of typos. So it's likely there's some typo in your code that's messing things up.

    Before you give up completely, could you perhaps zip up a compilable version, which has the maximizing problem, of all your stuff (icons/source files etc) and email it to me?

    danteshamest AT gmail DOT COM

    I'm just curious, and would like to get to the bottom of this.

  4. #49
    Registered User
    Join Date
    May 2005
    Posts
    207
    Uh- Sorry about that... The computer I program on doesn't have internet access so I had to retype it manually. It's a safety thing...

    I noticed some strange things about WS_MAXIMIZE and SW_SHOWMAXIMIZED when I started over:

    If I don't put WS_MAXIMIZE in my CreateWindow, then my buttons are off-centered.

    If I *do* put WS_MAXIMIZE in my CreateWindow, then my buttons are centered fine AS LONG AS I put WS_MAXIMIZE in my ShowWindow function as well.

    SW_SHOWMAXIMIZED is just plain weird and I can't even find it on Microsoft's library website.

    Also, a new problem has come up: my program compiles and runs fine except that nothing shows up on the screen?! I have to shut it down from the Task Manager.

    Since I didn't delete the program that I couldn't get working, I went back to that in desperation and it does the same thing too!?

    I don't think I have a virus, since the computer I program on doesn't get on the internet.

    This is why I hate Microsoft.

    mw
    Last edited by Lionmane; 10-14-2005 at 12:10 PM.
    Blucast Corporation

  5. #50
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    The computer I program on doesn't have internet access so I had to retype it manually. It's a safety thing...
    Couldn't you save it into a disk, then open it up in the other computer that connects to the
    internet?

    SW_SHOWMAXIMIZED is just plain weird and I can't even find it on Microsoft's library website.
    It's here.

    This is why I hate Microsoft.
    I don't think it's a problem with Microsoft, really. If it isn't just your program, then alot of applications would be having this strange maximizing problem.

    To test that it's just your program, try compiling the following code exactly and without making any changes. See if it displays a fullscreen maximized window. If it does, you can use it as your base code.

    Code:
    #include <windows.h>
    
    HWND hwndMain ;
    
    LRESULT CALLBACK WndProc( HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam )
    {
      switch(msg)  
      {
        case WM_DESTROY:
          {
            PostQuitMessage(0);
            return 0;
          }
          
        default: return DefWindowProc(hwnd,msg,wParam,lParam);
      }
    }
    
    int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrev, LPSTR args, int nShow )
    {
      MSG  msg ;    
      WNDCLASS wc = {0};
      wc.lpszClassName = TEXT( "TestClass" );
      wc.hInstance     = hInst ;
      wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
      wc.lpfnWndProc   = WndProc ;
      wc.hCursor       = LoadCursor(0,IDC_ARROW);
      
      RegisterClass(&wc);
      hwndMain = CreateWindow( wc.lpszClassName,TEXT("Maximized Window"),
                               WS_OVERLAPPED|WS_VISIBLE|WS_MAXIMIZE,
                               0,0,300,200,0,0,hInst,0);
      
      while( GetMessage(&msg,0,0,0) > 0 ) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
      }
      return (int)msg.wParam;
    }
    Last edited by Dante Shamest; 10-14-2005 at 01:35 PM.

  6. #51
    Registered User
    Join Date
    May 2005
    Posts
    207
    I noticed in your window procedure you don't declare HWND as hwndMain. Why is that? Are they not the same?

    mw
    Blucast Corporation

  7. #52
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    hwndMain is the global one (below the #include <windows.h>) line

    hwnd is the one inside the window procedure.

    Both handles refer to the same window.

  8. #53
    Registered User
    Join Date
    May 2005
    Posts
    207
    How does Windows know they're both the same window?

    The program doesn't create a maximized window. It creates a small window (300 x 200) in the top-left corner of the screen.

    Also I had to move "MSG msg" to the top of the WinMain function to get it to compile. Is that ok?

    I'm using Windoes XP home edition and MSVC++ ver 6.0 if that makes a difference...

    mw
    Blucast Corporation

  9. #54
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    How does Windows know they're both the same window?
    Because I only create one window.

    Also I had to move "MSG msg" to the top of the WinMain function to get it to compile. Is that ok?
    Yes, it should be okay. I forgot you're using C. Anyway, I've edited the code to reflect the changes. You've not changed anything else, right?

    The program doesn't create a maximized window. It creates a small window (300 x 200) in the top-left corner of the screen.
    Hmm, very strange indeed. I admit, I am totally stumped. It creates a fullscreen maximized window on my computer.

    I'm using Windows XP Professional, Dev-C++.

    Edit: Wait, if I run my program outside my IDE, I get the same thing as you.

    But if I add this code

    Code:
    ShowWindow( hwndMain, SW_SHOWMAXIMIZED );
    After CreateWindow, I get a maximized window everytime.
    Last edited by Dante Shamest; 10-14-2005 at 01:43 PM.

  10. #55
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Okay, I've uploaded my program that comes with an .EXE and .C

    http://www.abdn.ac.uk/~u02cll2/maximized.zip

    Check whether it maximizes on your computer.

  11. #56
    Registered User
    Join Date
    May 2005
    Posts
    207
    If I do the ShowWindow like you did then I get the maximized window too.

    What is "IDE"?

    I'll have to wait for my friend to bring the USB floppy... :-)

    mw
    Blucast Corporation

  12. #57
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    If I do the ShowWindow like you did then I get the maximized window too.
    Cool. Hope we're getting closer to solving this.

    What is "IDE"?
    Integrated Development Environment. Basically your development environment. For me, it's Dev-C++.

  13. #58
    Registered User
    Join Date
    May 2005
    Posts
    207
    Ok, I ran the executeable and it maximized the window BUT...

    The source code has the "ShowWindow( hwndMain, SW_SHOWMAXIMIZED );" function in it. Did you intend to include that?

    mw
    Blucast Corporation

  14. #59
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Yes. If you see the styles I passed inside CreateWindow(), there was only WS_OVERLAPPED.

  15. #60
    Registered User
    Join Date
    May 2005
    Posts
    207
    But I thought we were testing to see if it would maximize normally (ie: without the ShowWindow)...?

    mw
    Blucast Corporation

Page 4 of 6 FirstFirst 123456 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 06-28-2008, 08:30 PM
  2. elliptical button
    By geek@02 in forum Windows Programming
    Replies: 0
    Last Post: 11-21-2006, 01:15 AM
  3. Remove dialog button border
    By RedZone in forum Windows Programming
    Replies: 4
    Last Post: 08-21-2006, 01:20 PM
  4. writing text over a deleted button
    By algi in forum Windows Programming
    Replies: 4
    Last Post: 05-02-2005, 11:32 AM
  5. Window won't display on button command!?
    By psychopath in forum Windows Programming
    Replies: 6
    Last Post: 06-22-2004, 08:12 PM

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