www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - Problems with APP in WIN32 based

Problems with APP in WIN32 based.  (Problem in command line compilation. not
in IDDE)

the backgraund color text in standard "STATIC" windows component difers of
the main window color.
Source code and make.bat as follows:

cpp file:
/////////////////////////////////////////////////////////////
#include <windows.h>
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
char szClassName[ ] = "Tttt";
HWND hwnd;
HWND hwnd0;
HWND hwnd1;
HWND hwnd2;
HWND hwnd3;
HWND hwnd4;
HWND hwnd5;
HWND hwnd6;
HWND hwnd7;
HWND hwnd8;
HWND hwnd9;
HWND hwnd10;
HWND hwnd11;
 WNDCLASSEX wincl;
 MSG messages;
 HFONT TextFont;
void Proc0()
{
     //Code for &SAIRclick
PostQuitMessage(0);
}
void Proc1()
{
     //Code for &OKclick
MessageBox(hwnd,"BOTÃO OK CLICADO","CLIQUE",MB_ICONINFORMATION);
}


int WINAPI WinMain (HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR
lpszArgument,int nFunsterStil)
{
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;
    wincl.style = CS_DBLCLKS;
    wincl.cbSize = sizeof (WNDCLASSEX);
    wincl.hIcon = LoadIcon (NULL, IDI_WINLOGO);
    wincl.hIconSm = LoadIcon (NULL, IDI_WINLOGO);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;
    wincl.cbClsExtra = 0;
    wincl.cbWndExtra = 0;
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
    if (!RegisterClassEx (&wincl))
        return 0;
hwnd = CreateWindowEx (WS_EX_APPWINDOW,szClassName,
      "Album",
                       WS_BORDER | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION
| WS_SIZEBOX,
         101,
              60,
              597,
              386,
                        HWND_DESKTOP,NULL,hThisInstance,NULL);
  hwnd0 = CreateWindowEx(
  0,"BUTTON","&SAIR",WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  483,318,75,25,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd1 = CreateWindowEx(
  0,"BUTTON","&OK",WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  399,318,75,25,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd2 = CreateWindowEx(
  0,"STATIC","Foto",WS_VISIBLE | WS_CHILD | SS_LEFT,
  14,13,316,278,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd3 = CreateWindowEx(
  0,"BUTTON","Dados",WS_CHILD | BS_GROUPBOX | WS_VISIBLE,
  372,15,207,278,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd4 = CreateWindowEx(
  0,"STATIC","Nome:",WS_VISIBLE | WS_CHILD | SS_LEFT,
  389,39,58,17,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd5 = CreateWindowEx(
  WS_EX_CLIENTEDGE,"EDIT","",WS_CHILD | ES_LEFT | WS_VISIBLE |
ES_AUTOHSCROLL,
  390,59,121,21,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd6 = CreateWindowEx(
  WS_EX_CLIENTEDGE,"EDIT","",WS_CHILD | ES_LEFT | WS_VISIBLE |
ES_AUTOHSCROLL,
  392,114,121,21,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd7 = CreateWindowEx(
  0,"STATIC","Endereço:",WS_VISIBLE | WS_CHILD | SS_LEFT,
  391,96,58,17,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd8 = CreateWindowEx(
  0,"STATIC","Telefone:",WS_VISIBLE | WS_CHILD | SS_LEFT,
  392,150,58,17,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd9 = CreateWindowEx(
  WS_EX_CLIENTEDGE,"EDIT","",WS_CHILD | ES_LEFT | WS_VISIBLE |
ES_AUTOHSCROLL,
  391,166,121,21,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd10 = CreateWindowEx(
  0,"STATIC","E-mail:",WS_VISIBLE | WS_CHILD | SS_LEFT,
  393,198,58,17,
  hwnd,NULL,GetModuleHandle(0),NULL);
  hwnd11 = CreateWindowEx(
  WS_EX_CLIENTEDGE,"EDIT","",WS_CHILD | ES_LEFT | WS_VISIBLE |
ES_AUTOHSCROLL,
  390,218,121,21,
  hwnd,NULL,GetModuleHandle(0),NULL);
    TextFont = CreateFont(8,0,0,0,FW_DONTCARE,0,0,0,
        DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
        DEFAULT_QUALITY,DEFAULT_PITCH | FF_DONTCARE,"MS Sans Serif");
 SendMessage(hwnd0,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd1,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd2,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd3,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd4,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd5,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd6,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd7,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd8,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd9,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd10,WM_SETFONT,(DWORD)TextFont,0);
 SendMessage(hwnd11,WM_SETFONT,(DWORD)TextFont,0);
    ShowWindow (hwnd, nFunsterStil);
    while (GetMessage (&messages, NULL, 0, 0))
    {
        TranslateMessage(&messages);
        DispatchMessage(&messages);
    }
    return messages.wParam;
}
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
    switch (message)
    {
        case WM_DESTROY:
            PostQuitMessage (0);
            break;
        case WM_COMMAND: {
        if (lParam == (LPARAM)hwnd0)  Proc0();
        else if (lParam == (LPARAM)hwnd1) Proc1();

            break;
        }
        default:
            return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;
}
//////////////////////////////////////////////////////////
bat file:
////////////////////////////////////////////////
 ECHO OFF
path=C:\dm\bin
cl /c ttt.cpp
link /SUBSYSTEM:WINDOWS ttt.obj user32.lib gdi32.lib
pause
Jul 22 2007