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

[WinAPI, C++] pojawiające się pole po kliknięciu przycisku

Ostatnio zmodyfikowano 2012-05-09 23:50
Autor Wiadomość
xevuel
» 2012-05-05 16:25:23
Przepraszam, mój błąd. Zmień
C/C++
if( bChecked =( IsDlgButtonChecked( hWnd, ID_SHOWONP ) == BST_CHECKED ) )
na
C/C++
if(( bChecked = IsDlgButtonChecked( hWnd, ID_SHOWONP ) ) == BST_CHECKED )
i powinno działać.
P-56068
RayTango19
Temat założony przez niniejszego użytkownika
» 2012-05-05 17:07:20
i nic nie daje nie wiem sam.
P-56069
xevuel
» 2012-05-05 17:10:02
A odznacza/zaznacza ci checkboxa?
P-56071
RayTango19
Temat założony przez niniejszego użytkownika
» 2012-05-05 17:12:51
checkboxa odznaczało i odznacza .tylko on nie rozpoznaje w :
C/C++
hText6 = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER |
WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 380, 430, 200, 450, hWnd, NULL, hInstance, NULL );
parametru hInstance mówi że jest nie zdefiniowany .Ale pomimo tego program normalnie działa
P-56072
xevuel
» 2012-05-05 17:15:55
Jakby był niezdefiniowany, to by ci cię nie skompilowało. Ten argument musisz ustawić na hInstance okna dialogowego lub ten co masz w funkcji WinMain.
P-56073
RayTango19
Temat założony przez niniejszego użytkownika
» 2012-05-05 17:18:33
wlasnie ze jest na hInstance ustawiony nic nie zmieniałem
P-56074
xevuel
» 2012-05-05 17:21:42
Co nie zmieniałeś? Taki kod miałeś zaraz po otworzeniu projektu? Wątpię. W poprzednim poście napisałem ci co ma być ustawione. Nie mam całego kodu, więc nie mogę ci powiedzieć na 100% co jest błędem, ale skoro mówisz że to coś z hInstance... Jakbyś dał cały kod, prędzej bym ci pomógł.
P-56075
RayTango19
Temat założony przez niniejszego użytkownika
» 2012-05-05 17:27:33
C/C++
TCHAR * rownanie;
HINSTANCE hInst;
BOOL bChecked;
// Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
HWND hText, hText2, hText3, hText4, hText5, clean, x_variable, hText6;
HWND listview;
DWORD dlugosc;
bool show_onp;
LPWSTR Bufor;
int x, y;
bool odp;
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
    WNDCLASSEX wcex;
   
    wcex.cbSize = sizeof( WNDCLASSEX );
    wcex.style = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc = WndProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInstance;
    wcex.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_APPLICATION ) );
    wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
    wcex.hbrBackground =( HBRUSH )( COLOR_WINDOW + 1 );
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = szWindowClass;
    wcex.hIconSm = LoadIcon( wcex.hInstance, MAKEINTRESOURCE( IDI_APPLICATION ) );
   
    if( !RegisterClassEx( & wcex ) )
    {
        MessageBox( NULL,
        _T( "Call to RegisterClassEx failed!" ),
        _T( "Win32 Guided Tour" ),
        NULL );
       
        return 1;
    }
   
    hInst = hInstance; // Store instance handle in our global variable
    //hdcOkno= GetDC( hWnd );
    // The parameters to CreateWindow explained:
    // szWindowClass: the name of the application
    // szTitle: the text that appears in the title bar
    // WS_OVERLAPPEDWINDOW: the type of window to create
    // CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
    // 500, 100: initial size (width, length)
    // NULL: the parent of this window
    // NULL: this application does not have a menu bar
    // hInstance: the first parameter from WinMain
    // NULL: not used in this application
    HWND g_hPrzycisk, sqrt, abs, tan, ctg;
    HWND przycisk_1, przycisk_2, przycisk_3, przycisk_4, przycisk_5, przycisk_6, przycisk_7, przycisk_8, przycisk_9, sin, cos, LICZ;
    HWND pokazONP, asin, acos, actan, atan, nawiasy, ln, exp;
    HWND plus, minus, iloczyn, dziel, rowne, zero;
   
    //WND hStatic;
    HWND hWnd = CreateWindow(
    szWindowClass,
    szTitle,
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, CW_USEDEFAULT,
    1000, 700,
    NULL,
    NULL,
    hInstance,
    NULL
    );
   
   
    hText = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
    20, 30, 220, 20, hWnd, NULL, hInstance, NULL );
    hText2 = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER |
    WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 780, 130, 200, 450, hWnd, NULL, hInstance, NULL );
    hText3 = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 800
    , 30, 50, 20, hWnd, NULL, hInstance, NULL );
    hText4 = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 800
    , 60, 50, 20, hWnd, NULL, hInstance, NULL );
    hText5 = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 900
    , 30, 50, 20, hWnd, NULL, hInstance, NULL );
    SetWindowText( hText, L"Wpisz funkcje " );
    g_hPrzycisk = CreateWindowEx( 0, L"BUTTON", L"Rysuj wykres3", WS_CHILD | WS_VISIBLE,
    10, 70, 150, 30, hWnd,( HMENU ) ID_PRZYCISK20, hInstance, NULL );
   
    pokazONP = CreateWindowEx( 0, L"BUTTON", L"Pokaz ONP", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
    50, 550, 150, 30, hWnd,( HMENU ) ID_SHOWONP, hInstance, NULL );
    /*** tu sa zdefiniowane przyciski*/
   
    if( !hWnd )
    {
        MessageBox( NULL,
        _T( "Call to CreateWindow failed!" ),
        _T( "Wykresy" ),
        NULL );
       
        return 1;
    }
    DWORD dlugosc = GetWindowTextLength( hText );
    LPWSTR Bufor =( LPWSTR ) GlobalAlloc( GPTR, dlugosc + 1 );
    GetWindowText( hText, Bufor, dlugosc + 1 );
    // The parameters to ShowWindow explained:
    // hWnd: the value returned from CreateWindow
    // nCmdShow: the fourth parameter from WinMain
    ShowWindow( hWnd,
    nCmdShow );
    UpdateWindow( hWnd );
    MessageBox( NULL, L"Wpisuj poprawne równania !!!\nDozwolone symbole :+,-,*,/,^\nNie wolno używać spacji\nDostepne funkcje:sin,cos,tg,ctg,log\n", L"Witaj użytkowniku", MB_ICONASTERISK );
    // Main message loop:
    MSG msg;
    while( GetMessage( & msg, NULL, 0, 0 ) )
    {
        TranslateMessage( & msg );
        DispatchMessage( & msg );
    }
   
    return( int ) msg.wParam;
}

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    PAINTSTRUCT ps;
    HDC hdc;
   
    TCHAR greeting[] = _T( "Wpisz wzór :" );
    TCHAR napis1[] = _T( "Pomiary : " );
    TCHAR napis2[] = _T( "f(x)=" );
    TCHAR n[] = _T( "n=" );
    TCHAR x[] = _T( "x=" );
    TCHAR delta;
    HWND hStatic;
    switch( message )
    {
    case WM_PAINT:
        hdc = BeginPaint( hWnd, & ps );
        LineTo( hdc, 21, 10 ); ////linia przykladowa
        // Here your application is laid out.
        // For this introduction, we just print out "Hello, World!"
        // in the top left corner.
        TextOut( hdc, 5, 5, greeting, _tcslen( greeting ) );
        TextOut( hdc, 875, 30, n, _tcslen( n ) );
        TextOut( hdc, 780, 30, x, _tcslen( x ) );
        TextOut( hdc, 780, 60, x, _tcslen( x ) );
        // End application-specific layout section.
        // ReleaseDC( hWnd, hdcOkno );
        TextOut( hdc, 790, 5, napis1, _tcslen( napis1 ) );
        HPEN CzerwonePioro, Pudelko; POINT stary;
        HBRUSH PedzelZiel, Piornik;
        PedzelZiel = CreateSolidBrush( 0x000000 );
        CzerwonePioro = CreatePen( PS_SOLID, 1, 0x0000FF );
        Pudelko =( HPEN ) SelectObject( hdc, CzerwonePioro );
        Piornik =( HBRUSH ) SelectObject( hdc, PedzelZiel );
       
        Rectangle( hdc, 750, 550, 250, 50 );
        ReleaseDC( hWnd, hdc );
        EndPaint( hWnd, & ps );
        break;
    case WM_COMMAND:
        switch( wParam )
        {
           
        case ID_SHOWONP:
            show_onp = true;
            if(( bChecked = IsDlgButtonChecked( hWnd, ID_SHOWONP ) ) == BST_CHECKED )
            {
                CheckDlgButton( hWnd, ID_SHOWONP, BST_UNCHECKED );
                show_onp = false;
            }
            else
            {
                CheckDlgButton( hWnd, ID_SHOWONP, BST_CHECKED );
                show_onp = true;
            }
           
            if( show_onp == true )
            {
                hText6 = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER |
                WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 380, 430, 200, 450, hWnd, NULL, hInstance, NULL );
            }
            break;
            default:
            break;
        }
        break;
    case WM_DESTROY:
        MessageBox( NULL, L"Czy jesteś tego pewien???", L"Wyjście", MB_YESNO );
        PostQuitMessage( 0 );
        break;
        default:
        return DefWindowProc( hWnd, message, wParam, lParam );
        break;
    }
   
    return 0;
}
troche to uszczupliłem i zachowałem ten przycisk z ONP
P-56076
1 « 2 » 3
Poprzednia strona Strona 2 z 3 Następna strona