CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Display issues

Threaded View

  1. #1
    Join Date
    Nov 2014
    Posts
    37

    Display issues

    This has been driving me crazy for a couple of days and I cannot find the problem.
    All the c/c++ compilers I have (PellesC,TDM-GCC,NUWEN,Tiny C)display this code the same except Visual Studio 2015 Community.
    VS chops the bottom and right side of the window.

    James

    Code:
    #include <windows.h>
    #pragma comment(lib,"User32.lib")
    #pragma comment(lib,"gdi32.lib")
    #define cSizeOfDefaultString 2048
    
    #define IDC_OK 1001
    #define IDC_CANCEL 1002
    #define IDC_TEXT 1003
    
    static HWND    hText;
    static HWND    hOk;
    static HWND    hCancel;
    
    int     WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
    
    
    int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR CmdLine, int CmdShow)
    {
        WNDCLASSEX  wcx = {0};
        MSG      uMsg = {0};
        HWND     hWin = {0};
        DWORD    dwStyle = {0};
        DWORD    dwStyleEx = {0};
        HFONT    hFont = {0};
        hFont = ( HFONT) GetStockObject( DEFAULT_GUI_FONT);
        char     szClassName[] = "MyClassName";
        wcx.cbSize = sizeof( wcx);
        wcx.style = CS_HREDRAW | CS_VREDRAW;
        wcx.lpfnWndProc = WndProc;
        wcx.cbClsExtra = 0;
        wcx.cbWndExtra = 0;
        wcx.hInstance = hInst;
        wcx.hIcon = LoadIcon( NULL, IDI_APPLICATION);
        wcx.hCursor = LoadCursor( NULL, IDC_ARROW);
        wcx.hbrBackground = ( HBRUSH)( COLOR_BTNFACE + 1);
        wcx.lpszMenuName = 0;
        wcx.lpszClassName = szClassName;
        wcx.hIconSm = LoadIcon( NULL, IDI_APPLICATION);
        RegisterClassEx( &wcx);
    
        dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION;
        dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE;
        hWin = CreateWindowEx( dwStyleEx, szClassName, "What is your name? ", dwStyle, ( GetSystemMetrics( SM_CXSCREEN) - 246) / 2, ( GetSystemMetrics( SM_CYSCREEN) - 110) / 2, 246, 110, 0, (HMENU) 0, hInst, NULL);
        hText = CreateWindowEx( WS_EX_CLIENTEDGE, "Edit", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL, 21, 20, 201, 19, hWin, (HMENU) IDC_TEXT, hInst, NULL);
        SendMessage(hText, (UINT)WM_SETFONT, (WPARAM)hFont, (LPARAM)0);
        hOk = CreateWindowEx( 0, "Button", "OK", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 51, 52, 60, 23, hWin, (HMENU) IDC_OK, hInst, NULL);
        SendMessage(hOk, (UINT)WM_SETFONT, (WPARAM)hFont, (LPARAM)0);
        hCancel = CreateWindowEx( 0, "Button", "Cancel", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 126, 52, 60, 23, hWin, (HMENU) IDC_CANCEL, hInst, NULL);
        SendMessage(hCancel, (UINT)WM_SETFONT, (WPARAM)hFont, (LPARAM)1);
        SetFocus(hText);
        ShowWindow(hWin, SW_SHOW);
        while(GetMessage( &uMsg, NULL, 0, 0))
        {
            if(IsDialogMessage(hWin, &uMsg))
            {
                continue;
            }
            TranslateMessage( &uMsg);
            DispatchMessage( &uMsg);
        }
    
        return uMsg.wParam;
    }
    
    
    LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
        switch(Msg)
        {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        case WM_COMMAND:
            if((HWND)lParam == hCancel )
            {
                SendMessage(hWnd, (UINT)WM_CLOSE, (WPARAM)0, (LPARAM)0);
            }
        }
        return DefWindowProc(hWnd, Msg, wParam, lParam);
    }
    Attached Images Attached Images   

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured