Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[CPP] [WinAPI] Dziwny przebieg działania programu

Ostatnio zmodyfikowano 2015-05-17 21:42
Autor Wiadomość
TheReclif
Temat założony przez niniejszego użytkownika
» 2015-05-10 15:43:03
Ok. Trochę to trwało, ale zrobiłem coś, co nazwałem eventMgr. Zmienię jeszcze strukturę klasy handlingClass i mam nadzieję, że wtedy okno będzie się prawidłowo tworzyło. W razie jakichkolwiek problemów jeszcze napiszę na forum w tym wątku.
P-132029
TheReclif
Temat założony przez niniejszego użytkownika
» 2015-05-11 23:05:56
Zdaje mi się, że coś jest nie tak z funkcją tworzącą okno i inicjującą jego klasę:
C/C++
void windowClass::create( LPCSTR winName, UINT width, UINT height, bool fullscreen, bool hideCursor )
{
    this->fullscreen = fullscreen;
    this->winName = const_cast < LPSTR >( winName );
    DEVMODE dmScreenSettings;
    UINT screenW, screenH, posX, posY;
    // Determine the resolution of the clients desktop screen
    screenW = GetSystemMetrics( SM_CXSCREEN );
    screenH = GetSystemMetrics( SM_CYSCREEN );
   
    // Setup the screen settings depending on whether it is running in full screen or in windowed mode
    if( fullscreen )
    {
        // If full screen set the screen to maximum size of the users desktop and 32bit
        memset( & dmScreenSettings, 0, sizeof( dmScreenSettings ) );
        dmScreenSettings.dmSize = sizeof( dmScreenSettings );
        dmScreenSettings.dmPelsWidth =( unsigned long ) screenW;
        dmScreenSettings.dmPelsHeight =( unsigned long ) screenH;
        dmScreenSettings.dmBitsPerPel = 32;
        dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
       
        this->width = screenW;
        this->height = screenH;
       
        // Change the display settings to full screen
        ChangeDisplaySettings( & dmScreenSettings, CDS_FULLSCREEN );
       
        // Set the position of the window to the top left corner
        posX = posY = 0;
    }
    else
    {
        // Place the window in the middle of the screen
        posX =( GetSystemMetrics( SM_CXSCREEN ) - screenW ) / 2;
        posY =( GetSystemMetrics( SM_CYSCREEN ) - screenH ) / 2;
    }
   
    // Create the window with the screen settings and get the handle to it
    * win = CreateWindowEx( WS_EX_APPWINDOW, winClassName, this->winName,
    WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP,
    posX, posY, width, height, NULL, NULL, GetModuleHandle( NULL ), NULL );
   
    // Bring the window up on the screen and set it as main focus
    ShowWindow( * win, SW_SHOW );
    SetForegroundWindow( * win );
    SetFocus( * win );
   
    // Hide the mouse cursor.
    ShowCursor( hideCursor );
}

void windowClass::init( HICON icon, HCURSOR cursor )
{
    wndclass wc;
    int posX, posY;
   
    // Setup the windows class with default settings
    wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    wc.lpfnWndProc = stdDefProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = GetModuleHandle( NULL );
    wc.hIcon = icon;
    wc.hIconSm = wc.hIcon;
    wc.hCursor = cursor;
    wc.hbrBackground =( HBRUSH ) GetStockObject( BLACK_BRUSH );
    wc.lpszMenuName = NULL;
    wc.lpszClassName = winClassName;
    wc.cbSize = sizeof( WNDCLASSEX );
   
    // Register the window class
    if( !RegisterClassEx( & wc ) )
    {
        throw WNDCLASS_RECORDER_ERROR;
    }
   
}
Teraz proces nie zostaje w menadżerze zadań, ale przez chwilę przy kursorze kręci się kółko ładowania.
P-132108
TheReclif
Temat założony przez niniejszego użytkownika
» 2015-05-17 21:42:19
Wreszcie działa. Zrobiłem parę większych zmian w kodzie, ale cały czas nie działało. Okazało się, że po prostu w pętli głównej programu nie było nic, co miałoby związek z odświeżaniem ekranu/okna. Temat zamykam, bo okienko ładnie się tworzy(ale z zamykaniem jest już problem, dam w innym wątku).
P-132435
1 2 « 3 »
Poprzednia strona Strona 3 z 3