Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    [C++ Win32] Creare una status bar

    Salve,

    sto cercando di creare uan status bar via codice:

    codice:
    #define STRICT
    #include <windows.h>
    #include <windowsx.h>
    #pragma comment (lib, "comctl32.lib")
    #include <commctrl.h>
    
    (...)
    #define IDC_STATUSBAR 600
    
    HINSTANCE hInst; // Gloabl
    (...)
    
    // HANDLE_MSG (hWnd, WM_CREATE, Cls_OnCreate);
    //
    BOOL Cls_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct)
    {
    	InitCommonControls();
    	HWND hWndStatus = CreateWindowEx(0,TEXT("STATUSCLASSNAME"),NULL,
    					SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE,0, 0, 0, 0,
    						hwnd,(HMENU)IDC_STATUSBAR,hInst,NULL);
    
    	if (hWndStatus == NULL)
    	{
    		MessageBox (NULL, TEXT("Status Bar not created!"), NULL, MB_OK );
    		return false;
    	}
    	return true;
    }
    Ho seguito le linee guida di MSDN: http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

    ma purtroppo quando eseguo il codice si apre la MessageBox() :-(

    cosa sto sbagliando?

    grazie
    Alla batteria dai retta ballA

  2. #2
    STATUSCLASSNAME non è l'effettivo nome della classe della statusbar, ma una macro che si espande in esso. Quindi:
    codice:
    	HWND hWndStatus = CreateWindowEx(0,STATUSCLASSNAME,NULL,
    					SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE,0, 0, 0, 0,
    						hwnd,(HMENU)IDC_STATUSBAR,hInst,NULL);
    .
    Amaro C++, il gusto pieno dell'undefined behavior.

  3. #3
    ma non mi funzionerebbe! avevo provato già quel codice ma devo per forza includere TEXT() in quanto sto in ambito <tchar.h>
    Alla batteria dai retta ballA

  4. #4
    mi sa che forse l'ho sparata grossa
    Alla batteria dai retta ballA

  5. #5
    Mi sa di sì.
    Amaro C++, il gusto pieno dell'undefined behavior.

  6. #6
    Utente di HTML.it L'avatar di mamo139
    Registrato dal
    May 2005
    residenza
    Londra
    Messaggi
    841
    su msdn dice che InitCommonControls serve solo su win95

  7. #7
    Che io sappia bisogna richiamarlo sempre, ma è deprecato in favore di InitCommonControlsEx.
    Amaro C++, il gusto pieno dell'undefined behavior.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.