CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2014
    Posts
    37

    VS 2015 display issue

    I was updating some turn of the century code when I ran into this anomaly using Visual Studio 2015 Community c++.
    It appears to be a display issue because I have an app that produces source (PowerBASIC) from a running applications window. The sizes for the window and the edit controls match the sizes used in the c++ code for both displays .
    I tested with the TDM-GCC compiler (http://tdm-gcc.tdragon.net/) for the c++ code and also using PellesC compiler.
    I did a few preliminary tests compiling on Win10 and running on Win7 and Compiling on Win7 and running on Win7. I also tested on different computers with different monitor resolutions just to be sure. All results were the same. The Visual Studio 2015 created app did not display correctly. Any insights?
    Thank you for your time.
    James

    Code:
    #include <windows.h>
    
    // *************************************************
    //            User Defined Constants
    // *************************************************
    
    #define AppName "Ec03"
    #define Caption "Edit Controls"
    #define ID_Edit1 101
    #define ID_Edit2 102
    // *************************************************
    //            User Global Variables
    // *************************************************
    static HWND    Form1;
    static HWND    Edit1;
    static HWND    Edit2;
    
    // *************************************************
    //               Standard Macros
    // *************************************************
    
    #define BOR |
    
    
    // *************************************************
    //               User Prototypes
    // *************************************************
    
    void    FormLoad (HINSTANCE);
    int     WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
    
    
    void FormLoad (HINSTANCE  hInst)
    {
        float    fHeight = 312;
        float    fWidth = 330;
        Form1 = CreateWindowEx( WS_EX_WINDOWEDGE, AppName, Caption, WS_POPUP  BOR  WS_VISIBLE  BOR  WS_CLIPSIBLINGS  BOR  WS_CAPTION  BOR  WS_SYSMENU  BOR  DS_MODALFRAME, ( GetSystemMetrics( SM_CXSCREEN) - fWidth) / 2, ( GetSystemMetrics( SM_CYSCREEN) - fHeight) / 2, fWidth, fHeight, NULL, (HMENU) NULL, hInst, NULL);
        Edit1 = CreateWindowEx( 0, "edit", NULL, WS_CHILD  BOR  WS_VISIBLE  BOR  WS_BORDER  BOR  ES_AUTOVSCROLL  BOR  ES_WANTRETURN  BOR  ES_AUTOHSCROLL  BOR  ES_MULTILINE, 14, 16, 300, 110, Form1, (HMENU) ID_Edit1, hInst, NULL);
        Edit2 = CreateWindowEx( 0, "edit", NULL, WS_CHILD  BOR  WS_VISIBLE  BOR  WS_BORDER  BOR  ES_AUTOVSCROLL  BOR  ES_WANTRETURN  BOR  ES_AUTOHSCROLL  BOR  ES_MULTILINE, 14, 158, 300, 116, Form1, (HMENU) ID_Edit2, hInst, NULL);
        ShowWindow(Form1, SW_SHOW);
    }
    
    int WINAPI WinMain (HINSTANCE  hInst, HINSTANCE  hPrev, LPSTR  CmdLine, int CmdShow)
    {
        MSG      uMsg = {0};
        WNDCLASSEX  wcx = {0};
        wcx.cbSize = sizeof( wcx);
        wcx.style = CS_HREDRAW  BOR  CS_VREDRAW;
        wcx.lpfnWndProc = WndProc;
        wcx.cbClsExtra = 0;
        wcx.cbWndExtra = 0;
        wcx.hInstance = hInst;
        wcx.hIcon = LoadIcon( NULL, IDI_WINLOGO);
        wcx.hCursor = LoadCursor( NULL, IDC_ARROW);
        wcx.hbrBackground = ( HBRUSH) GetStockObject( WHITE_BRUSH);
        wcx.lpszMenuName = NULL;
        wcx.lpszClassName = AppName;
        RegisterClassEx( &wcx);
        FormLoad(hInst);
        while(GetMessage( &uMsg, NULL, 0, 0))
        {
            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;
        }
        return DefWindowProc(hWnd, Msg, wParam, lParam);
    }
    Visual Studio 2015 batch file
    @SETLOCAL
    @ECHO OFF
    SET XTYPE=x86_amd64
    CALL "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %XTYPE%
    ECHO ON
    cl.exe /O1 /Gd /EHsc /MT %1.cpp /Fe"%1.exe" /link /SUBSYSTEM:WINDOWS kernel32.lib user32.lib gdi32.lib
    TDM-GCC batch file
    @SETLOCAL
    @ECHO OFF
    SET MINGW=C:\TDM-GCC-64
    SET PATH=%MINGW%\bin;%PATH%
    ECHO ON
    g++ %1.cpp -o %1.exe -mwindows -lmingw32 -lkernel32 -luser32 -lgdi32
    Attached Images Attached Images   
    Attached Files Attached Files
    Last edited by jcfuller; March 23rd, 2016 at 01:04 PM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: VS 2015 display issue

    Quote Originally Posted by jcfuller View Post
    ...
    I did a few preliminary tests compiling on Win10 and running on Win7 and Compiling on Win7 and running on Win7. I also tested on different computers with different monitor resolutions just to be sure. All results were the same. The Visual Studio 2015 created app did not display correctly. Any insights?
    Well, which one of the two images is correct and how was it built?
    Victor Nijegorodov

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: VS 2015 display issue

    [moved from Visual C++ Programming forum...]
    Victor Nijegorodov

  4. #4
    Join Date
    Nov 2014
    Posts
    37

    Re: VS 2015 display issue

    Quote Originally Posted by VictorN View Post
    Well, which one of the two images is correct and how was it built?

    The image on the left is the correct display created with TDM-GCC.
    The image on the right is not correct created with visual studio 2015 community.

    The visual studio version was created using the visual studio 2015 batch file from a normal command prompt.
    The TDM-GCC version was created using the TDM-GCC batch file from a normal command prompt.

    James

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: VS 2015 display issue

    The display produced from the code in post #1 and the attached zip doesn't produce the expected image - even the window caption is different
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #6
    Join Date
    Nov 2014
    Posts
    37

    Re: VS 2015 display issue

    Thank you 2kaud.
    Updated first post.

    James

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: VS 2015 display issue

    On my Windows 7 system using VS2015, to get a display like the required left image, fHeight is 335 rather than 312 and fWidth is 345 rather than 330. I don't have access to the other compilers so can't comment upon what these numbers will show with them. However, how the created windows are displayed surely seems more inclined to be based upon the version of user32.dll used than the compilers - as all the compilers are doing is creating code that calls the functions in the windows dll files?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  8. #8
    Join Date
    Nov 2014
    Posts
    37

    Re: VS 2015 display issue

    I tried it with vs2013 Express on Win7 with the same results as VS 2015 community.
    All other languages I tried create what I believe is the correctly displayed window.
    PellesC
    TDM-GCC
    NUWEN
    FreeBasic
    PowerBASIC

    James

  9. #9
    Join Date
    Nov 2014
    Posts
    37

    Re: VS 2015 display issue

    I received an email report that VC15 (from Visual Studio 2008 - 64 bit) produced a correct display.

    James

  10. #10
    Join Date
    Nov 2014
    Posts
    37

    Re: VS 2015 display issue

    I don't know if this is a clue but:
    On Win10 with the exe built on Win10, if I change compatibility in File Explorer->propterties of the exe to Windows 7 it displays correctly.
    On Win7 with the exe built on Win7 no difference on any compatibility changes.

    James

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