title image


Smiley Re: Toolbar in WIN32API
hi :)endlich mal was interessantes über api.weiter unten findest du ein programm, dass eine toolbar über api erstellt. ich habe es nicht dokumentiert, aber vielleicht hilft es dir ja trotzdem weiter.viel spass damit!p.s.: im zusammenhang damit kann ich nur dieses buch empfehlen:Windows 95 ProgrammierungCharles PetzoldMicrosoft Press Deutschland 1996ISBN 3-86063-335-xmfgkwoTxquellcode:#include "windows.h"#include "commctrl.h" //spitze klammern waren nicht möglich *g*#define IDM_FILE_NEW 100#define _WM_TNA WM_USER#define BEZ "Taskbar Programm"#define SBEZ "Taskbar Programm Correlation"#define ToolBar_AutoSize(hwnd) \ (void)SendMessage((hwnd), TB_AUTOSIZE, 0, 0L)#define Status_SetText(hwnd, iPart, uType, szText) \ (BOOL)SendMessage((hwnd), SB_SETTEXT, (WPARAM) (iPart | uType), (LPARAM) (LPSTR) szText)NOTIFYICONDATA NID={sizeof(NID),0,0,NIF_MESSAGE|NIF_ICON|NIF_TIP,_WM_TNA,0,BEZ};HWND hWndMain,hWnd,shWnd,hwndToolBar=0,hwndStatusBar=0;RECT r;int x0,y0,cx=0,cy=0;BOOL bTopmost=FALSE;RECT rStatus;int cyStatus;DWORD dwSBStyles=WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|CCS_BOTTOM|SBARS_SIZEGRIP;DWORD dwTBStyles=WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|CCS_TOP;TBBUTTON tbb={STD_FILENEW, IDM_FILE_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON};void GetWindowCoords(){ //Fensterpositionierung: wird später aus INI-Datei gelesen! SystemParametersInfo(SPI_GETWORKAREA,0,&r,0); /*if(cx==0)*/cx=(r.right/3)+1; /*if(cy==0)*/cy=(r.bottom/3)+1;// x0=r.right-cx;//(2*r.right)/3;// y0=r.bottom-cy;//(2*r.bottom)/3; x0=(2*r.right)/3; y0=(2*r.bottom)/3;}void UpdateTNAIcon() {if(bTopmost)Shell_NotifyIcon(NIM_DELETE,&NID);}LRESULT CALLBACK WndSProc(HWND hwnd,UINT Msg,WPARAM wp,LPARAM lp){ shWnd=hwnd; switch(Msg){ case WM_CREATE: LPTBBUTTON ptbb; ptbb=&tbb; hwndStatusBar=CreateStatusWindow(dwSBStyles,"Ready",shWnd,2); hwndToolBar=CreateToolbarEx(shWnd,dwTBStyles,1,1,HINST_COMMCTRL, IDB_STD_SMALL_COLOR,ptbb,1,0,0,0,0,sizeof(TBBUTTON)) ; break; case WM_SIZE: cx=LOWORD(lp); cy=HIWORD(lp); GetWindowRect(hwndStatusBar,&rStatus); cyStatus=rStatus.bottom-rStatus.top; MoveWindow(hwndStatusBar,0,cy-cyStatus,cx,cyStatus,TRUE); ToolBar_AutoSize(hwndToolBar); InvalidateRect(hwndToolBar,0,1); break; case WM_COMMAND: if(LOWORD(wp)==IDM_FILE_NEW)Status_SetText(hwndStatusBar,0,0,"klick!"); break; case WM_SYSCOMMAND: switch(wp){ case SC_MINIMIZE: ShowWindow(shWnd,SW_HIDE); Shell_NotifyIcon(NIM_ADD,&NID); return 1; case SC_MAXIMIZE: return 1; } break; case WM_DESTROY: SendMessage(hWnd,WM_DESTROY,0,0L); PostQuitMessage(0); break; } return DefWindowProc(hwnd,Msg,wp,lp);}LRESULT CALLBACK WndProc(HWND hwnd,UINT Msg,WPARAM wp,LPARAM lp){ hWnd=hwnd; switch(Msg){ case WM_CREATE: NID.hWnd=hwnd; NID.hIcon=LoadIcon(0,IDI_WINLOGO); Shell_NotifyIcon(NIM_ADD,&NID); break; case _WM_TNA: switch(lp){ case WM_LBUTTONUP: case WM_MBUTTONUP: GetWindowCoords(); SetWindowPos(shWnd,(bTopmost)?HWND_TOPMOST:HWND_NOTOPMOST,x0,y0,cx,cy,SWP_SHOWWINDOW); UpdateTNAIcon(); SetForegroundWindow(shWnd); return 0; case WM_RBUTTONUP: HMENU hm=CreatePopupMenu(); POINT p; GetCursorPos(&p); AppendMenu(hm,MF_STRING|(bTopmost)?MF_CHECKED:MF_UNCHECKED,0,"Immer im Vordergrund"); AppendMenu(hm,MF_STRING,1,"Beenden"); SetForegroundWindow(hWnd); TrackPopupMenu(hm,TPM_RIGHTALIGN,p.x,p.y,0,hwnd,NULL); if(GetMenu(hWnd))DestroyMenu(hm); return 0; } return 0; case WM_COMMAND: if(wp==0){ bTopmost^=1; CheckMenuItem(GetMenu(hWnd),0,(bTopmost)?MF_CHECKED:MF_UNCHECKED); GetWindowCoords(); SetWindowPos(shWnd,(bTopmost)?HWND_TOPMOST:HWND_NOTOPMOST,x0,y0,cx,cy,(bTopmost)?SWP_SHOWWINDOW:0); UpdateTNAIcon(); } if(wp==1){ Shell_NotifyIcon(NIM_DELETE,&NID); SendMessage(shWnd,WM_DESTROY,0,0L); } return 0; case WM_DESTROY: Shell_NotifyIcon(NIM_DELETE,&NID); DestroyIcon(NID.hIcon); PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,Msg,wp,lp);}int WINAPI WinMain(HINSTANCE hi,HINSTANCE,PSTR,int nShow){ nShow=SW_HIDE; MSG msg; hWndMain=FindWindow(SBEZ,0); if(hWndMain){ if(IsWindowVisible(hWndMain))SetForegroundWindow(hWndMain);else MessageBoxEx(0,"Schlaubert! Schau mal in die TNA!","Hinweis...",MB_ICONINFORMATION,LANG_GERMAN); return 0; } WNDCLASS wc={0,WndProc,0,0,hi,0,0,0,0,BEZ}; WNDCLASS wsc={CS_HREDRAW|CS_VREDRAW,WndSProc,0,0,hi, LoadIcon(0,IDI_APPLICATION),LoadCursor(0,IDC_ARROW), (HBRUSH)GetStockObject(LTGRAY_BRUSH),0,SBEZ}; RegisterClass(&wc); RegisterClass(&wsc); CreateWindow(BEZ,BEZ,0,0,0,0,0,NULL,NULL,hi,NULL); hWndMain=CreateWindowEx(WS_EX_DLGMODALFRAME|WS_EX_TOPMOST,SBEZ,SBEZ, WS_OVERLAPPEDWINDOW,0,0,0,0,0,0,hi,0); GetWindowCoords(); ShowWindow(hWndMain,nShow); UpdateWindow(hWndMain); InitCommonControls(); while(GetMessage(&msg,0,0,0)){ TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam;}

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: