Toolbar avec texte+bmp

s@ldon Messages postés 140 Date d'inscription samedi 1 novembre 2003 Statut Membre Dernière intervention 30 septembre 2009 - 31 mars 2004 à 15:37
ymca2003 Messages postés 2070 Date d'inscription mardi 22 avril 2003 Statut Membre Dernière intervention 3 juillet 2006 - 1 avril 2004 à 15:30
salut, ben voila, je cherche a creer une barre d'outils avec des boutons texte+bitmap, un peu comme celles de winrar, eMule, ...

1 réponse

ymca2003 Messages postés 2070 Date d'inscription mardi 22 avril 2003 Statut Membre Dernière intervention 3 juillet 2006 7
1 avril 2004 à 15:30
un bout de code qui crée une barre d'outils avec 2 boutons avec botmpa+texte
le bitmap avec les boutons est IDB_TOOLBAR

// création barre d'outils
InitCommonControls();
m_hWndToolBar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,WS_CHILD|WS_CLIPSIBLINGS|WS_TABSTOP|TBSTYLE_TOOLTIPS|TBSTYLE_LIST|TBSTYLE_FLAT|TBSTYLE_TRANSPARENT|CCS_NODIVIDER|CCS_NORESIZE,0,0,0,0,hWndParent, 0,g_hDllInstance, NULL);
if(!m_hWndToolBar) return -1;

// affectation informations diverses
SendMessage(m_hWndToolBar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
SendMessage(m_hWndToolBar, TB_SETMAXTEXTROWS, 1, 0L);
SendMessage(m_hWndToolBar, TB_SETBITMAPSIZE, 0, MAKELONG(16, 16));
SendMessage(m_hWndToolBar, TB_SETBUTTONSIZE, 0, MAKELONG(23, 22));

// texte des boutons
SendMessage(m_hWndToolBar, TB_ADDSTRING, 0,(LPARAM) "Bouton1");
SendMessage(m_hWndToolBar, TB_ADDSTRING, 0,(LPARAM) "Bouton2");

// ajout du bitmap avec les boutons
TBADDBITMAP tbBmp;
tbBmp.hInst = g_hAppInstance;
tbBmp.nID = IDB_TOOLBAR;
SendMessage(m_hWndToolBar, TB_ADDBITMAP, 2, (LPARAM) &tbBmp);

// ajout boutons
TBBUTTON btn;
ZeroMemory(&btn, sizeof(TBBUTTON));
btn.idCommand = IDTBBTN_1;
btn.iString = 0;
btn.iBitmap = 0;
btn.fsState = TBSTATE_ENABLED;
btn.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE;
SendMessage(m_hWndToolBar, TB_ADDBUTTONS, 1, (LPARAM) &btn);

ZeroMemory(&btn, sizeof(TBBUTTON));
btn.idCommand = IDTBBTN_2;
btn.iString = 1;
btn.iBitmap = 1;
btn.fsState = TBSTATE_ENABLED;
btn.fsStyle = TBSTYLE_BUTTON | TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE;
SendMessage(m_hWndToolBar, TB_ADDBUTTONS, 1, (LPARAM) &btn);
0
Rejoignez-nous