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

Kompilowanie pliku .rc .

Ostatnio zmodyfikowano 2011-01-03 17:28
Autor Wiadomość
kt1117
Temat założony przez niniejszego użytkownika
» 2011-01-01 15:11:26
Miałem takie coś. Teraz działa, dzięki za wszystko.
E:Czyli jeśli mam plik dodany do projektu to nie mogę go dołączyć za pomocą "#include"?
Mam jeszcze jedno pytanie, a mianowicie, jak wygląda procedura zdarzeniowa niemodalnego okna dialogowego?
Mam taki kod w pliku .cpp:
C/C++
#include <string>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>

HWND hPrzyc;
HWND hwnd; /* This is the handle for our window */
MSG messages;
MSG msg; /* Here messages to the application are saved */
WNDCLASSEX wincl;
HWND hPasek;
HWND dial;
/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure( HWND, UINT, WPARAM, LPARAM );
BOOL CALLBACK DlgProc( HWND, UINT, WPARAM, LPARAM );

/*  Make the class name into a global variable  */
char szClassName[] = "CodeBlocksWindowsApp";

int WINAPI WinMain( HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil )
{
    /* Data structure for the windowclass */
   
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
    wincl.style = CS_DBLCLKS; /* Catch double-clicks */
    wincl.cbSize = sizeof( WNDCLASSEX );
   
    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon( NULL, IDI_APPLICATION );
    wincl.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
    wincl.hCursor = LoadCursor( NULL, IDC_ARROW );
    wincl.lpszMenuName = NULL; /* No menu */
    wincl.cbClsExtra = 0; /* No extra bytes after the window class */
    wincl.cbWndExtra = 0; /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground =( HBRUSH ) COLOR_BACKGROUND;
   
    /* Register the window class, and if it fails quit the program */
    if( !RegisterClassEx( & wincl ) )
         return 0;
   
    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx(
    0, /* Extended possibilites for variation */
    szClassName, /* Classname */
    "Code::Blocks Template Windows App", /* Title Text */
    WS_OVERLAPPEDWINDOW, /* default window */
    CW_USEDEFAULT, /* Windows decides the position */
    CW_USEDEFAULT, /* where the window ends up on the screen */
    544, /* The programs width */
    375, /* and height in pixels */
    HWND_DESKTOP, /* The window is a child-window to desktop */
    NULL, /* No menu */
    hThisInstance, /* Program Instance handler */
    NULL /* No Window Creation data */
    );
   
    /* Make the window visible on the screen */
    ShowWindow( hwnd, nFunsterStil );
    CreateDialog( GetModuleHandle( NULL ), MAKEINTRESOURCE( 200 ), hwnd, DlgProc );
    //hPrzyc = CreateWindowEx( 0, "BUTTON", "Dialog", WS_CHILD | WS_VISIBLE,
    // 5, 5, 50, 25, hwnd, NULL, hThisInstance, NULL );
   
   
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while( GetMessage( & messages, NULL, 0, 0 ) )
    {
        if( !IsDialogMessage( hPasek, & msg ) )
        {
            TranslateMessage( & msg );
            DispatchMessage( & msg );
        }
       
       
    }
   
    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    switch( message ) /* handle the messages */
    {
        break;
    case WM_DESTROY:
        PostQuitMessage( 0 ); /* send a WM_QUIT to the message queue */
        break;
        default: /* for messages that we don't deal with */
        return DefWindowProc( hwnd, message, wParam, lParam );
    }
   
    return 0;
}
BOOL CALLBACK DlgProc( HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam )
{
    switch( Msg )
    {
    case WM_INITDIALOG:
        {
           
        }
        break;
    case WM_COMMAND:
        {
        }
        break;
        default: return FALSE;
    }
    return TRUE;
}
, w .h:

#define IDD_PASEK  200
#define IDC_PRZYC1 201
#define IDC_PRZYC1 202
#define IDC_PRZYC1 203
i w .rc

#include <windows.h>

IDD_PASEK DIALOGEX 0, 0, 98, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Mój pasek narzêdzi"
FONT 8, "MS Sans Serif"
{
     PUSHBUTTON "&Pierwszy przycisk", IDC_PRZYC1, 7, 7, 84, 14
     PUSHBUTTON "&Drugi przycisk", IDC_PRZYC2, 7, 31, 84, 14
    PUSHBUTTON "&Trzeci przycisk", IDC_PRZYC3, 7, 31, 84, 14
}
, i wyskakuje mi błąd:

syntax error
, a gdy usunę linijki zaczynające się od słowa PUSHBUTTON,
kod kompiluje się, lecz w wyniku dostaję okno, które nie reaguje na "bodźce zewnętrzne" i nic poza tym.
P-26076
kt1117
Temat założony przez niniejszego użytkownika
» 2011-01-02 18:09:22
Pokombinowałem trochę i stworzyłem taki kod:
C/C++
#include <windows.h>


HWND hPrzyc;
HWND hwnd; /* This is the handle for our window */
MSG messages;
MSG Msg; /* Here messages to the application are saved */
WNDCLASSEX wincl;
HWND hPasek;
HWND dial;
/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure( HWND, UINT, WPARAM, LPARAM );
BOOL CALLBACK DlgProc( HWND, UINT, WPARAM, LPARAM );

/*  Make the class name into a global variable  */
char szClassName[] = "CodeBlocksWindowsApp";

int WINAPI WinMain( HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil )
{
    /* Data structure for the windowclass */
   
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
    wincl.style = CS_DBLCLKS; /* Catch double-clicks */
    wincl.cbSize = sizeof( WNDCLASSEX );
   
    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon( NULL, IDI_APPLICATION );
    wincl.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
    wincl.hCursor = LoadCursor( NULL, IDC_ARROW );
    wincl.lpszMenuName = NULL; /* No menu */
    wincl.cbClsExtra = 0; /* No extra bytes after the window class */
    wincl.cbWndExtra = 0; /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground =( HBRUSH ) COLOR_BACKGROUND;
   
    /* Register the window class, and if it fails quit the program */
    if( !RegisterClassEx( & wincl ) )
         return 0;
   
    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx(
    0, /* Extended possibilites for variation */
    szClassName, /* Classname */
    "Code::Blocks Template Windows App", /* Title Text */
    WS_OVERLAPPEDWINDOW, /* default window */
    CW_USEDEFAULT, /* Windows decides the position */
    CW_USEDEFAULT, /* where the window ends up on the screen */
    544, /* The programs width */
    375, /* and height in pixels */
    HWND_DESKTOP, /* The window is a child-window to desktop */
    NULL, /* No menu */
    hThisInstance, /* Program Instance handler */
    NULL /* No Window Creation data */
    );
   
    /* Make the window visible on the screen */
    ShowWindow( hwnd, nFunsterStil );
    hPasek = CreateDialog( hThisInstance, MAKEINTRESOURCE( 200 ), hwnd, DlgProc );
    //hPrzyc = CreateWindowEx( 0, "BUTTON", "Dialog", WS_CHILD | WS_VISIBLE,
    // 5, 5, 50, 25, hwnd, NULL, hThisInstance, NULL );
   
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while( GetMessage( & messages, NULL, 0, 0 ) )
    {
        if( !IsDialogMessage( hPasek, & Msg ) )
        {
            TranslateMessage( & messages );
            DispatchMessage( & messages );
        }
       
       
    }
   
    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure( HWND hwnd, UINT messages, WPARAM wParam, LPARAM lParam )
{
    switch( messages ) /* handle the messages */
    {
        break;
    case WM_DESTROY:
        PostQuitMessage( 0 ); /* send a WM_QUIT to the message queue */
        break;
        default: /* for messages that we don't deal with */
        return DefWindowProc( hwnd, messages, wParam, lParam );
    }
   
    return 0;
}
BOOL CALLBACK DlgProc( HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam )
{
    switch( Msg )
    {
    case WM_INITDIALOG:
        {
           
        }
        break;
    case WM_COMMAND:
        { // reakcja na przyciski
           
        }
        break;
        default: return FALSE;
    }
    return TRUE;
}
, teraz gdy wcześniej wspomniane trzy linijki z PUSHBUTTON na początku są, usunięte kod kompiluje się, i powstaje okno, ale tylko jedno, główne i daje się przesuwać wyłączać itd. lecz dalej nie potrafię stworzyć tego niemodalnego. Jak to zrobić?
P-26135
DejaVu
» 2011-01-02 18:45:05
Dla mnie nie ma tematu do rozmowy z prostego powodu - kod jest przekopiowany skądśtam i twierdzisz, że coś tam robisz wspaniałego z nim. To nie jest efekt Twojej pracy. Poczytaj kurs WinAPI to będziesz wiedział co jest do czego.
P-26141
kt1117
Temat założony przez niniejszego użytkownika
» 2011-01-02 20:19:57
Właśnie ten kod wziąłem z kursu WinApi, naczy nie w całości, bo tam były wskazówki jak to zrobić i postępowałem zgodnie z nimi, i teraz za bardzo nie wiem co z nim zrobić, bo co chwilę wyskakują bugi, to wycinam  ten kod co te bugi powoduje, ale powstają nowe i nowe.
P-26153
DejaVu
» 2011-01-02 20:48:05
Kursy zazwyczaj się czyta od początku do końca, a nie od miejsca, które nas interesuje - nie wiesz co jak działa - cofnij się do poprzedniego rozdziału - i cofaj się aż do odnalezienia miejsca, którego nie rozumiesz albo zacznij czytać go od początku. Lepszej pomocy niż kurs nie dostaniesz chyba, że oczekujesz gotowca, których tutaj ja osobiście nie toleruję - przynajmniej nie na poziomie podstawowym, który jest wytłumaczony wystarczająco dobrze w wielu źródłach do których wystarczy po prostu sięgnąć.
P-26155
kt1117
Temat założony przez niniejszego użytkownika
» 2011-01-03 17:28:40
Sorry, że zawracałem wam głowę, nie wiedziałem co daje przebudowanie i nie korzystałem z niego, teraz przypadkowo nacisnąłem ten przycisk, i wszystko działa.
E:
Tylko nie działają PUSHBUTTON'y i LTEXT'y, ale poradzę sobie bez tego.
P-26185
1 « 2 »
Poprzednia strona Strona 2 z 2