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

Threaded View

  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.

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