Понедельник, 17 Июня 2024, 07:39

Приветствую Вас Гость

[ Новые сообщения · Игроделы · Правила · Поиск ]
  • Страница 1 из 1
  • 1
Дескриптор окна создаётся, самого окна нет
ТритонДата: Вторник, 24 Апреля 2012, 10:32 | Сообщение # 1
постоянный участник
Сейчас нет на сайте
Исходник:
Code
//=================================================================================================
#include <windows.h>
#include <fstream.h>
#include <iostream.h>
//=================================================================================================
#pragma comment( lib, "Gdi32.a" )
//=================================================================================================
std::ofstream    Log;
//=================================================================================================
bool             InitApplication           (HINSTANCE  Instance   );
//=================================================================================================
LRESULT CALLBACK WindowProcedureMainWindow (HWND       Window     ,
                      UINT       Message    ,
                      WPARAM     First      ,
                      LPARAM     Second     );
//=================================================================================================
int  WINAPI      WinMain                   (HINSTANCE  Instance   ,
                      HINSTANCE  Previus    ,
                      LPSTR      CommandLine,
                      int        Show       )
{
    MSG Message;
    Log.open("Log.Log");
    Log<<"WinMain                  ="<<(void *)WinMain                  <<"."<<endl;    
    Log<<"InitApplication          ="<<(void *)InitApplication          <<"."<<endl;
    Log<<"WindowProcedureMainWindow="<<(void *)WindowProcedureMainWindow<<"."<<endl;    
    Log<<"DefWindowProc            ="<<(void *)DefWindowProc            <<"."<<endl;     
    Log<<"WinMain is starting."<<endl;
    Log<<"Instance   ="<<(void *)Instance<<" at "<<(void *)&Instance<<"."<<endl;
    Log<<"Previus    ="<<(void *)Previus<<" at "<<(void *)&Previus<<"."<<endl;
    Log<<"CommandLine=\""<<CommandLine<<"\" at "<<(void *)CommandLine<<", pointer at "<<(void *)&CommandLine<<"."<<endl;
    Log<<"Show       ="<<Show<<" at "<<(void *)&Show<<"."<<endl;
    Log<<"Message at "<<(void *)&Message<<"."<<endl;
    if (InitApplication(Instance))
    {
     Log<<"WinMain is continueing."<<endl;
     Log<<"Main loop is starting."<<endl;
     while (GetMessage(&Message, NULL, 0, 0))
     {
      TranslateMessage(&Message);
      DispatchMessage (&Message);      
     }
     Log<<"Main loop is ending."<<endl;
    }
    else
    {
     Log<<"WinMain is continueing."<<endl;
    }
    Log<<"WinMain is ending with 0."<<endl;
    Log.close();    
    return 0;
}
//=================================================================================================
bool             InitApplication           (HINSTANCE  Instance   )
{
    char ApplicationName[16]="Sea jackals";
    char WindowClassMain[32]="Sea jackals.Window class.Main.";
    HWND WindowMain;
    WNDCLASSEX WindowClass;
    Log<<"InitApplication is starting."<<endl;
    Log<<"ApplicationName=\""<<ApplicationName<<"\" at "<<(void *)ApplicationName<<"."<<endl;
    Log<<"WindowClassMain=\""<<WindowClassMain <<"\" at "<<(void *)WindowClassMain<<"."<<endl;
    Log<<"Instance="<<(void *)Instance<<" at "<<(void *)&Instance<<"."<<endl;    
    WindowClass.cbSize       =        sizeof        (WindowClass                 );
    WindowClass.style        =        CS_HREDRAW|
                      CS_VREDRAW;
    WindowClass.lpfnWndProc  =        WindowProcedureMainWindow;
    WindowClass.cbClsExtra   =        0;
    WindowClass.cbWndExtra   =        0;
    WindowClass.hInstance    =        Instance;
    WindowClass.hIcon        =        LoadIcon      (NULL       , IDI_APPLICATION);
    WindowClass.hCursor      =        LoadCursor    (NULL       , IDC_ARROW      );
    WindowClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH                 );
    WindowClass.lpszMenuName =        NULL;
    WindowClass.lpszClassName=        WindowClassMain;
    WindowClass.hIconSm      =        LoadIcon      (NULL       , IDI_APPLICATION);
    Log<<"WindowClass at "<<(void *)&WindowClass<<"."<<endl;
    Log<<"WindowClass.cbSize       ="  <<        WindowClass.cbSize       <<" at "  <<(void *)&WindowClass.cbSize       <<"."<<endl;
    Log<<"WindowClass.style        ="  <<        WindowClass.style        <<" at "  <<(void *)&WindowClass.style        <<"."<<endl;
    Log<<"WindowClass.lpfnWndProc  ="  <<(void *)WindowClass.lpfnWndProc  <<" at "  <<(void *)&WindowClass.lpfnWndProc  <<"."<<endl;
    Log<<"WindowClass.cbClsExtra   ="  <<        WindowClass.cbClsExtra   <<" at "  <<(void *)&WindowClass.cbClsExtra   <<"."<<endl;
    Log<<"WindowClass.cbWndExtra   ="  <<        WindowClass.cbWndExtra   <<" at "  <<(void *)&WindowClass.cbWndExtra   <<"."<<endl;
    Log<<"WindowClass.hInstance    ="  <<(void *)WindowClass.hInstance    <<" at "  <<(void *)&WindowClass.hInstance    <<"."<<endl;
    Log<<"WindowClass.hIcon        ="  <<(void *)WindowClass.hIcon        <<" at "  <<(void *)&WindowClass.hIcon        <<"."<<endl;
    Log<<"WindowClass.hCursor      ="  <<(void *)WindowClass.hCursor      <<" at "  <<(void *)&WindowClass.hCursor      <<"."<<endl;
    Log<<"WindowClass.hbrBackground="  <<(void *)WindowClass.hbrBackground<<" at "  <<(void *)&WindowClass.hbrBackground<<"."<<endl;
    Log<<"WindowClass.lpszMenuName ="  <<(void *)WindowClass.lpszMenuName <<" at "  <<(void *)&WindowClass.lpszMenuName <<"."<<endl;
    Log<<"WindowClass.lpszClassName=\""<<        WindowClass.lpszClassName<<"\" at "<<(void *) WindowClass.lpszClassName<<", poinet at "<<(void *)&WindowClass.lpszClassName<<"."<<endl;
    Log<<"WindowClass.hIconSm      ="  <<(void *)WindowClass.hIconSm      <<" at "  <<(void *)&WindowClass.hIconSm      <<"."<<endl;
    RegisterClassEx(&WindowClass);
    Log<<"The main window class is registering."<<endl;
    WindowMain=CreateWindow(WindowClassMain    ,
                            ApplicationName    ,    
                            WS_OVERLAPPEDWINDOW,
                            CW_USEDEFAULT      ,
                            CW_USEDEFAULT      ,
                            CW_USEDEFAULT      ,
                            CW_USEDEFAULT      ,
                            NULL               ,
                            NULL               ,
                            Instance           ,
                            NULL               );
    Log<<"InitApplication is continueing."<<endl;
    Log<<"WindowMain="<<(void *)WindowMain<<" at "<<(void *)&WindowMain<<"."<<endl;    
    if (WindowMain)
    {
     Log<<"InitApplication is ending with true."<<endl;
     return true;    
    }
    Log<<"InitApplication is ending with false."<<endl;
    return false;
}
//=================================================================================================
LRESULT CALLBACK WindowProcedureMainWindow (HWND       Window     ,
                      UINT       Message    ,
                      WPARAM     First      ,
                      LPARAM     Second     )
{
    Log<<"WindowProcedureMainWindow is stating."<<endl;
    Log<<"Window ="<<(void *)Window<<" at "<<(void *)&Window <<"."<<endl;
    Log<<"Message="<<(void *)Window<<" at "<<(void *)&Message<<"."<<endl;
    Log<<"First  ="<<(void *)First <<" at "<<(void *)&First  <<"."<<endl;
    Log<<"Second ="<<(void *)Second<<" at "<<(void *)&Second <<"."<<endl;
    switch (Message)
    {
     case WM_DESTROY: Log<<"Message is WM_DESTROY."<<endl;
                      PostQuitMessage(0);
     break;
    }
    Log<<"WindowProcedureMainWindow is ending."<<endl;
    return DefWindowProc (Window, Message, First, Second);
}
//=================================================================================================
, лог:
Quote
WinMain =0x4013da.
InitApplication =0x40186c.
WindowProcedureMainWindow=0x40217c.
DefWindowProc =0x412290.
WinMain is starting.
Instance =0x400000 at 0x28fed0.
Previus =0 at 0x28fed4.
CommandLine="" at 0x8a4988, pointer at 0x28fed8.
Show =1 at 0x28fedc.
Message at 0x28fea0.
InitApplication is starting.
ApplicationName="Sea jackals" at 0x28fe70.
WindowClassMain="Sea jackals.Window class.Main." at 0x28fe50.
Instance=0x400000 at 0x28fe90.
WindowClass at 0x28fe10.
WindowClass.cbSize =48 at 0x28fe10.
WindowClass.style =3 at 0x28fe14.
WindowClass.lpfnWndProc =0x40217c at 0x28fe18.
WindowClass.cbClsExtra =0 at 0x28fe1c.
WindowClass.cbWndExtra =0 at 0x28fe20.
WindowClass.hInstance =0x400000 at 0x28fe24.
WindowClass.hIcon =0x10027 at 0x28fe28.
WindowClass.hCursor =0x10003 at 0x28fe2c.
WindowClass.hbrBackground=0x1900010 at 0x28fe30.
WindowClass.lpszMenuName =0 at 0x28fe34.
WindowClass.lpszClassName="Sea jackals.Window class.Main." at 0x28fe50, poinet at 0x28fe38.
WindowClass.hIconSm =0x10027 at 0x28fe3c.
The main window class is registering.
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28f8a4.
Message=0x20f1e at 0x28f8a8.
First =0 at 0x28f8ac.
Second =0x28f9fc at 0x28f8b0.
WindowProcedureMainWindow is ending.
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28f874.
Message=0x20f1e at 0x28f878.
First =0 at 0x28f87c.
Second =0x28f9f0 at 0x28f880.
WindowProcedureMainWindow is ending.
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28f87c.
Message=0x20f1e at 0x28f880.
First =0 at 0x28f884.
Second =0x28f9dc at 0x28f888.
WindowProcedureMainWindow is ending.
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28f874.
Message=0x20f1e at 0x28f878.
First =0 at 0x28f87c.
Second =0x28f9f0 at 0x28f880.
WindowProcedureMainWindow is ending.
InitApplication is continueing.
WindowMain=0x20f1e at 0x28fe4c.
InitApplication is ending with true.
WinMain is continueing.
Main loop is starting.
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28fd7c.
Message=0x20f1e at 0x28fd80.
First =0x1 at 0x28fd84.
Second =0 at 0x28fd88.
WindowProcedureMainWindow is ending.
. Согласно логу. дескриптор окна создан (
Quote
InitApplication is continueing.
WindowMain=0x20f1e at 0x28fe4c.
), оконная процедура сообщения получает (
Quote
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28f8a4.
Message=0x20f1e at 0x28f8a8.
First =0 at 0x28f8ac.
Second =0x28f9fc at 0x28f8b0.
WindowProcedureMainWindow is ending.
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28f874.
Message=0x20f1e at 0x28f878.
First =0 at 0x28f87c.
Second =0x28f9f0 at 0x28f880.
WindowProcedureMainWindow is ending.
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28f87c.
Message=0x20f1e at 0x28f880.
First =0 at 0x28f884.
Second =0x28f9dc at 0x28f888.
WindowProcedureMainWindow is ending.
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28f874.
Message=0x20f1e at 0x28f878.
First =0 at 0x28f87c.
Second =0x28f9f0 at 0x28f880.
WindowProcedureMainWindow is ending.
...
WindowProcedureMainWindow is stating.
Window =0x20f1e at 0x28fd7c.
Message=0x20f1e at 0x28fd80.
First =0x1 at 0x28fd84.
Second =0 at 0x28fd88.
WindowProcedureMainWindow is ending.
), WM_DESTROY среди них нет, главный цикл запустился (
Quote
WinMain is continueing.
Main loop is starting.
), но не завершился. Но ни самого окна, ни его закладки на панели я не вижу. Ни приложения, ни процесса от него нет даже в диспетчере задач. В чём здесь может быть дело? Как с этим бороться?


Не всё так плохо, как оно есть на самом деле.

Сообщение отредактировал Тритон - Среда, 25 Апреля 2012, 09:46
MatouДата: Вторник, 24 Апреля 2012, 10:36 | Сообщение # 2
Исходный коТ
Сейчас нет на сайте
ShowWindow();
UpdateWindow();



ТритонДата: Вторник, 24 Апреля 2012, 10:45 | Сообщение # 3
постоянный участник
Сейчас нет на сайте
Уже нашёл. Причём, случайно.

Не всё так плохо, как оно есть на самом деле.
  • Страница 1 из 1
  • 1
Поиск:

Все права сохранены. GcUp.ru © 2008-2024 Рейтинг