HWND createToolbar(HINSTANCE hInst, HWND hWnd) { #if 1 HBITMAP hBitmap = (HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(IDB_TOOLBAR), IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS); #else HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, "toolbar.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS); #endif HWND ret = CreateToolbarEx(hWnd, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 11, 30, NULL, (int)hBitmap, NULL, 0, //buttons set later 0, 0, 0, 0, sizeof(TBBUTTON)); addTools(ret); SendMessage(ret, TB_SETSTYLE, 0, TBSTYLE_FLAT | CCS_TOP | TBSTYLE_TOOLTIPS | //wrapable style doesn't work with separators //use nodivider to remove the two stupid pixel lines on top of the toolbar CCS_ADJUSTABLE | CCS_NODIVIDER | TBSTYLE_ALTDRAG); // | TBSTYLE_WRAPABLE);// ); SendMessage(ret, TB_AUTOSIZE, 0, 0); ShowWindow(ret, SW_SHOW); return ret; }
/*****************************Private*Routine******************************\ * VideoCd_OnCreate * \**************************************************************************/ BOOL VideoCd_OnCreate( HWND hwnd, LPCREATESTRUCT lpCreateStruct ) { InitCommonControls(); /* ** Create the toolbar and statusbar. */ g_hwndToolbar = CreateToolbarEx(hwnd, WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS | CCS_NODIVIDER, ID_TOOLBAR, NUMBER_OF_BITMAPS, hInst, IDR_TOOLBAR, tbButtons, DEFAULT_TBAR_SIZE, dxBitmap, dyBitmap, dxBitmap, dyBitmap, sizeof(TBBUTTON)); if(g_hwndToolbar == NULL) { return FALSE; } return TRUE; }
void CreateToolBar() { TBBUTTON ToolBtn[]= { {0,IDM_FILE_NEW,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0}, {1,IDM_FILE_OPEN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,1}, {2,IDM_FILE_SAVE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,2}, {4,0,0,TBSTYLE_SEP,0,0}, {3,IDM_EDIT_CUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,3}, {4,IDM_EDIT_COPY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,4}, {5,IDM_EDIT_PASTE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,5}, {4,0,0,TBSTYLE_SEP,0,0}, {6,IDM_SHAPE_SELECT,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,6}, {7,IDM_SHAPE_LINE,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,7}, {8,IDM_SHAPE_ELLIPSE,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,8}, {9,IDM_SHAPE_RECTANGLE,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,9}, {10,IDM_SHAPE_TEXT,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,10}, {11,IDM_SHAPE_BITMAP,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,11}, {12,IDM_SHAPE_META,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,12}, {4,0,0,TBSTYLE_SEP,0,0}, {13,IDM_SHAPE_PROPERTY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,13}, }; TCHAR *szToolText="새파일\0열기\0저장\0자르기\0복사\0붙이기" "\0선택\0선\0원\0사각형\0텍스트\0비트맵\0메타\0속성\0"; hToolBar=CreateToolbarEx(hWndMain, WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT , 99, 14, g_hInst, IDB_TOOLBAR, ToolBtn, 17, 16,15,16,15,sizeof(TBBUTTON)); SendMessage(hToolBar,TB_ADDSTRING,NULL,(LPARAM)szToolText); SendMessage(hToolBar,TB_AUTOSIZE,0,0); }
//------------------------------------------------------------------- HWND InitToolBar (HWND hwndParent, HINSTANCE hInst ) { int iNumButtons ; LPTBBUTTON ptbb ; instbak=hInst; ptbb = &tbb[21] ; iNumButtons = 15 ; hwndTB = CreateToolbarEx (hwndParent, dwToolBarStyles, 1, 15, hInst, IDB_TOOLBAR, ptbb, iNumButtons, 0, 0, 0, 0, sizeof (TBBUTTON)) ; // If requested, add to string list if (bStrings) ToolBar_AddString (hwndTB, 0, szTbStrings) ; // Store handle to tooltip control hwndToolTip = ToolBar_GetToolTips (hwndTB) ; // Set flat style to toolbar SetWindowLong(hwndTB, GWL_STYLE, GetWindowLong(hwndTB, GWL_STYLE) | TBSTYLE_FLAT); return hwndTB ; }
BOOL CreateTBar(HWND hWnd) { HIMC hIMC = NULL; BOOL fOpen; hWndToolBar = CreateToolbarEx(hWnd, WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS, TOOLBAR_ID, NUMIMAGES, hInst, IDB_BMP, tbButton, sizeof(tbButton)/sizeof(TBBUTTON), BUTTONWIDTH, BUTTONHEIGHT, IMAGEWIDTH, IMAGEHEIGHT, sizeof(TBBUTTON)); UpdateShowCandButton(); hIMC = ImmGetContext(hWndCompStr); fOpen = ImmGetOpenStatus(hIMC); UpdateShowOpenStatusButton(fOpen); ImmReleaseContext(hWndCompStr,hIMC); return (hWndToolBar != 0); }
void WinClass::CreateToolBar(HWND _hMain) { TBBUTTON ToolBtn[8]={ //bReserved, dwData, fsState, fsStyle, iBitmap, idCommand, iString {0,OBJECT,TBSTATE_ENABLED | TBSTATE_CHECKED,TBSTYLE_CHECKGROUP,0,0,0,0}, {1,TERRAIN,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,1}, //{2,12,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,2}, //{3,13,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0,0,3} }; TCHAR *szString=L"TEXTURE\0OBJECT\0"; INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwICC = ICC_BAR_CLASSES; InitCommonControlsEx(&InitCtrlEx); m_WC().m_hToolBar=CreateToolbarEx(_hMain, WS_CHILD | WS_VISIBLE | WS_BORDER, //| TBSTYLE_FLAT | TBSTYLE_TOOLTIPS, ID_TOOLBAR, 2, m_WC().m_Inst, 0, ToolBtn, 2, 16,16,16,16,sizeof(TBBUTTON)); SendMessage(m_WC().m_hToolBar,TB_ADDSTRING,NULL,(LPARAM)szString); TBREPLACEBITMAP rb; int bx, by; rb.hInstOld = rb.hInstNew = HINST_COMMCTRL; bx = 60; by = 0; rb.nButtons = 3; SendMessage(m_WC().m_hToolBar, TB_REPLACEBITMAP, 0, (LPARAM)&rb); SendMessage(m_WC().m_hToolBar, TB_SETBITMAPSIZE, 0, (LPARAM)MAKELONG(bx,by)); SendMessage(m_WC().m_hToolBar,TB_AUTOSIZE,0,0); }
HWND CreateEmptyToolbar(HWND hwndParent, int nBitmapIdx, int nBitmapWidth, int nCtrlId, DWORD dwExtraStyle) { HWND hwndTB; HIMAGELIST hImgList; hwndTB = CreateToolbarEx (hwndParent, TOOLBAR_STYLE|dwExtraStyle, nCtrlId, 0, 0, 0, NULL, 0, 0, 0, 0, 0, sizeof(TBBUTTON) ); //hImgList = ImageList_LoadBitmap(GetModuleHandle(0), MAKEINTRESOURCE(nBitmapIdx), // nBitmapWidth, 16, RGB(255,0,255)); hImgList = ImageList_LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(nBitmapIdx), nBitmapWidth, 16, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION); SendMessage(hwndTB, TB_SETIMAGELIST, 0, (LPARAM)hImgList); return hwndTB; return CreateWindowEx(0, TOOLBARCLASSNAME,0,WS_VISIBLE|WS_CHILD|TBSTYLE_FLAT| TBSTYLE_TRANSPARENT |CCS_NORESIZE|CCS_NODIVIDER, 0,0,0,0,hwndParent,0,0,0); //SendMessage(hToolBar, TB_SETSTYLE, 0, SendMessage(hToolBar, TB_GETSTYLE, 0,0 ) //& ~ TBSTYLE_TRANSPARENT); }
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow){ MSG messages; windowSetups(hThisInstance,hPrevInstance,lpszArgument,nCmdShow,wincl,WindowProcedure); mainWindow = new MainWindow(szClassName, "Main Window", WS_OVERLAPPEDWINDOW, new Dimensions(1376/2 - 500,768/2 - 300,1010,600), HWND_DESKTOP, hThisInstance, NULL); ::SetWindowLong(mainWindow->getInstance(), GWL_STYLE, GetWindowLong(mainWindow->getInstance(), GWL_STYLE)&~WS_SIZEBOX); ctrl_R = new ShortKey(mainWindow->getInstance(),0x52); ctrl_E = new ShortKey(mainWindow->getInstance(),0x45); toolBarInit(); hWndToolbar = CreateToolbarEx(mainWindow->getInstance(), WS_VISIBLE | WS_CHILD | WS_EX_OVERLAPPEDWINDOW, IDB_STANDARD, NUMBUTTONS, hThisInstance, IDB_STANDARD, tbrButtons, NUMBUTTONS, 32, 32, 32, 32, sizeof(TBBUTTON)); ShowWindow (mainWindow->getInstance(), nCmdShow); while (GetMessage (&messages, NULL, 0, 0)){ TranslateMessage(&messages); DispatchMessage(&messages); } return messages.wParam; }
BOOL TAreaConfirmDlg::EvCreate(LPARAM lParam) { POINT pt; ::GetCursorPos(&pt); FitMoveWindow(pt.x - 20, pt.y - 20); CheckDlgButton(CLIP_CHECK, *useClip); CheckDlgButton(SAVE_CHECK, *withSave); TBBUTTON tbb[MARKER_TB_MAX] = {{0}}; for (int i=0; i < MARKER_TB_MAX; i++) { tbb[i].iBitmap = i; tbb[i].idCommand = MARKER_OFFSET + i; tbb[i].fsState = TBSTATE_ENABLED; tbb[i].fsStyle = TBSTYLE_CHECKGROUP; }; tbb[4].fsState = 0; tbb[4].fsStyle = TBSTYLE_BUTTON; hToolBar = CreateToolbarEx(hWnd, WS_CHILD|WS_VISIBLE|TBSTYLE_TOOLTIPS, AREA_TOOLBAR, MARKER_TB_MAX, TApp::GetInstance(), MARKERTB_BITMAP, tbb, MARKER_TB_MAX, 0, 0, 16, 16, sizeof(TBBUTTON)); TBBUTTON tb = {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0}; ::SendMessage(hToolBar, TB_INSERTBUTTON, 4, (LPARAM)&tb); Show(); return TRUE; }
HWND WINAPI CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps, HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,INT iNumButtons) { return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, 0, 0, 0, 0, CCSIZEOF_STRUCT(TBBUTTON, dwData)); }
void toolbar_init(HWND hwMain) { HINSTANCE hInst; TBBUTTON tbbutton[] = { /* FIXME: Second member of array is actually the command. */ {0, GEOM_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0}, {1, ANAL_NEW, 0, TBSTYLE_BUTTON, 0, 0}, {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0L, -1}, {2, GEOM_BROWSE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0}, {3, ANAL_BROWSE, 0, TBSTYLE_BUTTON, 0, 0}, {4, ANAL_ABORT, 0, TBSTYLE_BUTTON, 0, 0}, //{4, GEOM_NEW, TBSTATE_ENABLED, TBSTYLE_CHECK, 0, 0}, {5, GEOM_APPLY, 0, TBSTYLE_BUTTON, 0, 0}, {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0L, -1}, {7, TOOLBAR_ZOOMOUT, 0, TBSTYLE_BUTTON, 0, 0}, //Enabled by Roozbeh {8, TOOLBAR_ZOOMIN, 0, TBSTYLE_BUTTON, 0, 0}, //Enabled by Roozbeh {9, TOOLBAR_ZOOMBACK, 0, TBSTYLE_BUTTON, 0, 0}, //Enabled by Roozbeh {10, TOOLBAR_GOLEFT, 0, TBSTYLE_BUTTON, 0, 0}, //Enabled by Roozbeh {11, TOOLBAR_GORIGHT, 0, TBSTYLE_BUTTON, 0, 0}, //Enabled by Roozbeh {12, TOOLBAR_GOUP, 0, TBSTYLE_BUTTON, 0, 0}, //Enabled by Roozbeh {13, TOOLBAR_GODOWN, 0, TBSTYLE_BUTTON, 0, 0}, //Enabled by Roozbeh //{6, TOOLBAR_PRINT, 0, TBSTYLE_BUTTON, 0, 0} //{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0L, -1}, //{9, TOOLBAR_PRINT, 0, TBSTYLE_BUTTON, 0, 0} }; #define NUMIMAGES 18 #define IMAGEWIDTH 16 #define IMAGEHEIGHT 16 #define BUTTONWIDTH 0 #define BUTTONHEIGHT 0 hInst = (HINSTANCE) GetWindowLong(hwMain, GWL_HINSTANCE); hToolBar = CreateToolbarEx(hwMain, WS_CHILD | TBSTYLE_TOOLTIPS | CCS_ADJUSTABLE, TOOLBAR_DDA_MAIN, NUMIMAGES, hInst, TOOLBAR_DDA_MAIN, tbbutton, sizeof(tbbutton)/sizeof(TBBUTTON), BUTTONWIDTH, BUTTONHEIGHT, IMAGEWIDTH, IMAGEHEIGHT, sizeof(TBBUTTON)); toolbar_set_visibility(1); }
// // Create a toolbar with one button in it, for // the pin-button // HWND CreatePinToolbar(HWND hwndDlg, UINT nCtrlId, BOOL fRightAligned) { RECT rect; RECT rc1, rc2; HWND hwndPin; static TBBUTTON tbbPin[] = { { 0, 0, TBSTATE_ENABLED, TBSTYLE_CHECK, {0} }, }; tbbPin[0].idCommand = nCtrlId; // Create the toolbar to hold pin bitmap hwndPin = CreateToolbarEx( hwndDlg, TOOLBAR_PIN_STYLES, //, nCtrlId, // toolbar ID (don't need) 2, // number of button images g_hInstance, // where the bitmap is IDB_PIN_BITMAP, // bitmap resource name tbbPin, // TBBUTTON structure sizeof(tbbPin) / sizeof(tbbPin[0]), 15,14,15,14, // sizeof(TBBUTTON) ); // Find out how big the button is, so we can resize the // toolbar to fit perfectly SendMessage(hwndPin, TB_GETITEMRECT, 0, (LPARAM)&rect); SetWindowPos(hwndPin, HWND_TOP, 0,0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOMOVE); // Setup the bitmap image SendMessage(hwndPin, TB_CHANGEBITMAP, nCtrlId, (LPARAM)MAKELPARAM(g_fKeepVisible, 0)); // Checked / Unchecked SendMessage(hwndPin, TB_CHECKBUTTON, nCtrlId, MAKELONG(g_fKeepVisible, 0)); GetClientRect(hwndDlg, &rc1); GetClientRect(hwndPin, &rc2); if(fRightAligned) SetWindowPos(hwndPin, 0, rc1.right - rc2.right-10, rc1.bottom-rc2.bottom-8,0,0,SWP_NOSIZE); else SetWindowPos(hwndPin, 0, rc1.left+10, rc1.bottom-rc2.bottom-8,0,0,SWP_NOSIZE); return hwndPin; }
HWND MyCreateToolbar(HWND hWnd) { HINSTANCE hInst; HWND hTool; TBADDBITMAP tb; int stdid; // インスタンスハンドルを取得 hInst = (HINSTANCE)GetWindowLongPtr(hWnd, GWL_HINSTANCE); hTool = CreateToolbarEx( hWnd, // 親ウィンドウ WS_CHILD | WS_VISIBLE, // ウィンドウスタイル ID_TOOLBAR, // コントロールID 3, // イメージの数 hInst, // インスタンスハンドル IDR_TOOLBAR1, // ツールバーのID tbb, // TBBUTTON構造体 3, // ボタンの数 0, // ボタンの幅 0, // ボタンの高さ 0, // イメージの幅 0, // イメージの高さ sizeof(TBBUTTON)); // TBADDBITMAP構造体のメンバをセットして // TB_ADDBITMAPメッセージを送る tb.hInst = HINST_COMMCTRL; tb.nID = IDB_STD_SMALL_COLOR; stdid = SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tb); // TBBUTTON構造体のiBitmapメンバを修正し、 // TB_ADDBUTTONSメッセージを送る tbb[3].iBitmap += stdid; tbb[4].iBitmap += stdid; tbb[5].iBitmap += stdid; SendMessage(hTool, TB_ADDBUTTONS, (WPARAM)3, (LPARAM)&tbb[3]); // ボタンの系統(VIEW系)が違うので、再度同様の操作をする tb.hInst = HINST_COMMCTRL; tb.nID = IDB_VIEW_SMALL_COLOR; stdid = SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tb); tbb[6].iBitmap += stdid; SendMessage(hTool, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&tbb[6]); // セパレーターの挿入 SendMessage(hTool, TB_INSERTBUTTON, (WPARAM)3, (LPARAM)&tb_sep); return hTool; }
/* * toolbar_create - StatusBarの作成 */ HWND toolbar_create(const HWND hWnd, const int id) { HWND hToolBar; hToolBar = CreateToolbarEx(hWnd, WS_CHILD | TBSTYLE_TOOLTIPS, id, BITMAP_CNT, hInst, IDR_TOOLBAR, tbb, sizeof(tbb) / sizeof(TBBUTTON), 0, 0, TBICONSIZE_X, TBICONSIZE_Y, sizeof(TBBUTTON)); SetWindowLong(hToolBar, GWL_STYLE, GetWindowLong(hToolBar, GWL_STYLE) | TBSTYLE_FLAT); SendMessage(hToolBar, TB_SETINDENT, TOOLBAR_INDENT, 0); if (option.viewer_show_toolbar == 1) { ShowWindow(hToolBar, SW_SHOW); } return hToolBar; }
//------------------------------------------------------------------- HWND InitToolBar (HWND hwndParent, HINSTANCE hInst ) { int iNumButtons ; LPTBBUTTON ptbb ; //UINT uiBitmap; instbak=hInst; ptbb = &tbb[21] ; iNumButtons = 15 ; /* if (bLargeIcons) uiBitmap=IDB_STD_LARGE_COLOR; else uiBitmap=IDB_STD_SMALL_COLOR; hwndTB = CreateToolbarEx (hwndParent, dwToolBarStyles, 1, 15, HINST_COMMCTRL, uiBitmap, ptbb, iNumButtons, 0, 0, 0, 0, sizeof (TBBUTTON)) ; */ hwndTB = CreateToolbarEx (hwndParent, dwToolBarStyles, 1, 15, hInst, IDB_TOOLBAR, ptbb, iNumButtons, 0, 0, 0, 0, sizeof (TBBUTTON)) ; // If requested, add to string list if (bStrings) ToolBar_AddString (hwndTB, 0, szTbStrings) ; // Store handle to tooltip control hwndToolTip = ToolBar_GetToolTips (hwndTB) ; // Set flat style to toolbar SetWindowLong(hwndTB, GWL_STYLE, GetWindowLong(hwndTB, GWL_STYLE) | TBSTYLE_FLAT); return hwndTB ; }
HWND QuickLaunchBar::Create(HWND hwndParent) { CONTEXT("QuickLaunchBar::Create()"); ClientRect clnt(hwndParent); HWND hwnd = CreateToolbarEx(hwndParent, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN| CCS_TOP|CCS_NODIVIDER|CCS_NOPARENTALIGN|CCS_NORESIZE| TBSTYLE_TOOLTIPS|TBSTYLE_WRAPABLE|TBSTYLE_FLAT, IDW_QUICKLAUNCHBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON)); if (hwnd) new QuickLaunchBar(hwnd); return hwnd; }
static BOOL InitInstance(HINSTANCE hInst, int nCmdShow) { HWND hWnd; WCHAR wszAppName[MAX_LOAD_STRING]; WCHAR wszTitle[MAX_LOAD_STRING]; TBBUTTON tB[] = { {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0}, {0, IDM_BIND, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}, {1, IDM_TYPELIB, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}, {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0}, {2, IDM_REGEDIT, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}, {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0}, {3, IDM_CREATEINST, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}, {4, IDM_RELEASEINST, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}, {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0}, {5, IDM_VIEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0} }; LoadStringW(hInst, IDS_APPNAME, wszAppName, sizeof(wszAppName)/sizeof(wszAppName[0])); LoadStringW(hInst, IDS_APPTITLE, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0])); hWnd = CreateWindowW(wszAppName, wszTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL); if(!hWnd) return FALSE; globals.hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD, wszTitle, hWnd, 0); globals.hToolBar = CreateToolbarEx(hWnd, WS_CHILD|WS_VISIBLE, 0, 1, hInst, IDB_TOOLBAR, tB, 10, 16, 16, 16, 16, sizeof(TBBUTTON)); SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, FALSE); SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, FALSE); SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, FALSE); globals.hMainWnd = hWnd; globals.hMainInst = hInst; globals.bExpert = TRUE; globals.dwClsCtx = CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; }
/* Draws the toolbar for the editor * Parameters: * hInstance - The instance to create the toolbar in * hwndParent - The parent of the toolbar * Returns: * The handle to the toolbar */ HWND DrawToolbar(HINSTANCE hInstance, HWND hwndParent) { HWND hTool; TBADDBITMAP tbBit; int newidx; TBBUTTON tbButtons[10] = { { STD_FILENEW, IDM_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, { STD_FILESAVE, IDM_SAVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0}, 0L, 0}, { STD_CUT, IDM_CUT, 0, TBSTYLE_BUTTON, {0}, 0L, 0}, { STD_COPY, IDM_COPY, 0, TBSTYLE_BUTTON, {0}, 0L, 0}, { STD_PASTE, IDM_PASTE, 0, TBSTYLE_BUTTON, {0}, 0L, 0}, { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0}, 0L, 0}, { STD_UNDO, IDM_UNDO, 0, TBSTYLE_BUTTON, {0}, 0L, 0}, { STD_REDOW, IDM_REDO, 0, TBSTYLE_BUTTON, {0}, 0L, 0}, { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0}, 0L, 0} }; TBBUTTON tbAddButtons[7] = { { 0, IDC_BOLD, TBSTATE_ENABLED, TBSTYLE_CHECK, {0}, 0L, 0}, { 1, IDC_UNDERLINE, TBSTATE_ENABLED, TBSTYLE_CHECK, {0}, 0L, 0}, { 2, IDC_COLOR, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, { 3, IDC_BGCOLOR, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0}, 0L, 0}, { 4, IDC_GOTO, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, { STD_FIND, IDC_FIND, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0} }; hTool = CreateToolbarEx(hwndParent, WS_VISIBLE|WS_CHILD|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS, IDC_TOOLBAR, 0, HINST_COMMCTRL, IDB_STD_SMALL_COLOR, tbButtons, 10, 0, 0, 100, 30, sizeof(TBBUTTON)); tbBit.hInst = hInstance; tbBit.nID = IDB_BITMAP1; newidx = SendMessage(hTool, TB_ADDBITMAP, (WPARAM)5, (LPARAM)&tbBit); tbAddButtons[0].iBitmap += newidx; tbAddButtons[1].iBitmap += newidx; tbAddButtons[2].iBitmap += newidx; tbAddButtons[3].iBitmap += newidx; tbAddButtons[5].iBitmap += newidx; SendMessage(hTool, TB_ADDBUTTONS, (WPARAM)7, (LPARAM)&tbAddButtons); return hTool; }
void CreateToolbar(HWND hwOwner) { TBBUTTON Buttons[3]; Buttons[0].iBitmap = 1; Buttons[0].idCommand = IDM_PROPSHEET; Buttons[0].fsState = TBSTATE_ENABLED; Buttons[0].fsStyle = TBSTYLE_BUTTON; Buttons[0].dwData = 0L; Buttons[0].iString = 0; Buttons[1].iBitmap = 2; Buttons[1].idCommand = IDM_UPDOWN; Buttons[1].fsState = TBSTATE_ENABLED; Buttons[1].fsStyle = TBSTYLE_BUTTON; Buttons[1].dwData = 0L; Buttons[1].iString = 0; Buttons[2].iBitmap = 0; Buttons[2].idCommand = IDM_ABOUT; Buttons[2].fsState = TBSTATE_ENABLED; Buttons[2].fsStyle = TBSTYLE_BUTTON; Buttons[2].dwData = 0L; Buttons[2].iString = 0; hWndToolbar=CreateToolbarEx (hwOwner, WS_VISIBLE | WS_CHILD | WS_BORDER | CCS_TOP | TBSTYLE_TOOLTIPS, ID_TOOLBAR, 3, hInstance, IDB_TOOLBAR, Buttons, 3, 16, 16, 16, 16, sizeof(TBBUTTON)); }
void gw_create_toolbar (GUI_WINDOW *gwp) { RECT rect; #if _MSC_VER <= 900 int i; #endif /* check that we can do it. */ if (!o_toolbar (gwp)) return; if (gwp->toolbarHWnd != NULL) return; /* get borders size */ cxborder = GetSystemMetrics (SM_CXBORDER); cyborder = GetSystemMetrics (SM_CYBORDER); /* create the toolbar */ #if _MSC_VER > 900 gwp->toolbarHWnd = CreateToolbarEx (gwp->frameHWnd, WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS, 1, 15, hInst, IDT_ELVIS, buttons, 21, 16, 15, 15, 14, sizeof (TBBUTTON)); #else gwp->toolbarHWnd = CreateToolbar (gwp->frameHWnd, WS_CHILD | WS_VISIBLE, 1, 15, hInst, IDT_ELVIS, buttons, 1); for (i = 1; i < 21; i++) SendMessage (gwp->toolbarHWnd, TB_ADDBUTTONS, 1, (LPARAM)&buttons[i]); #endif /* size the toolbar */ GetClientRect (gwp->frameHWnd, &rect); gw_size_toolbar (gwp, &rect); }
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam) // 윈도우 프로시져 { switch(iMessage) { case WM_CREATE: InitCommonControls(); hToolBar=CreateToolbarEx(hWnd, WS_CHILD | WS_VISIBLE, 103, 4, g_hInst,IDB_BITMAP1, ToolBtn, 5, 16,16,16,16,sizeof(TBBUTTON)); // 툴바를 생성한다. return 0; case WM_COMMAND: switch(LOWORD(wParam)) { case 10: // 제일 왼쪽 툴버튼의 핸들. case IDR_LOAD: // or FILE->LOAD가 눌러졌을때 memset(&OFN,0,sizeof(OPENFILENAME)); OFN.lStructSize=sizeof(OPENFILENAME); OFN.hwndOwner=hWnd; OFN.lpstrFile=lpstrFile; OFN.nMaxFile=256; OFN.lpstrInitialDir="c:\\"; if (GetOpenFileName(&OFN)!=0) { window_main.set_child_window(OFN); // OFN을 갖는 childWindow인스턴스 생성 } break; } return 0; case WM_DESTROY: PostQuitMessage(0); return 0; case WM_SIZE: SendMessage(hToolBar,TB_AUTOSIZE,0,0); // 툴바 사이즈 조절 return 0; } return (DefWindowProc(hWnd,iMessage,wParam,lParam)); }
LRESULT TaskBar::Init(LPCREATESTRUCT pcs) { if (super::Init(pcs)) return 1; /* FIXME: There's an internal padding for non-flat toolbar. Get rid of it somehow. */ _htoolbar = CreateToolbarEx(_hwnd, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN| CCS_TOP|CCS_NODIVIDER|TBSTYLE_LIST|TBSTYLE_TOOLTIPS|TBSTYLE_WRAPABLE,//|TBSTYLE_AUTOSIZE IDW_TASKTOOLBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON)); SendMessage(_htoolbar, TB_SETBUTTONWIDTH, 0, MAKELONG(TASKBUTTONWIDTH_MAX,TASKBUTTONWIDTH_MAX)); //SendMessage(_htoolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS); //SendMessage(_htoolbar, TB_SETDRAWTEXTFLAGS, DT_CENTER|DT_VCENTER, DT_CENTER|DT_VCENTER); //SetWindowFont(_htoolbar, GetStockFont(ANSI_VAR_FONT), FALSE); //SendMessage(_htoolbar, TB_SETPADDING, 0, MAKELPARAM(8,8)); #ifndef __MINGW32__ // TBMETRICS missing in MinGW (as of 20.09.2005) // set metrics for the Taskbar toolbar to enable button spacing TBMETRICS metrics; metrics.cbSize = sizeof(TBMETRICS); metrics.dwMask = TBMF_BARPAD | TBMF_BUTTONSPACING; metrics.cxBarPad = 0; metrics.cyBarPad = 0; metrics.cxButtonSpacing = 3; metrics.cyButtonSpacing = 3; SendMessage(_htoolbar, TB_SETMETRICS, 0, (LPARAM)&metrics); #endif _next_id = IDC_FIRST_APP; // register the taskbar window as task manager window to make the following call to RegisterShellHookWindow working if (g_SetTaskmanWindow) (*g_SetTaskmanWindow)(_hwnd); if (g_RegisterShellHookWindow) { LOG(TEXT("Using shell hooks for notification of shell events.")); (*g_RegisterShellHookWindow)(_hwnd); } else { LOG(TEXT("Shell hooks not available.")); SetTimer(_hwnd, 0, 200, NULL); } /* Alternatively we could use the RegisterShellHook() function in SHELL32, but this is not yet implemented in the WINE code. if (g_RegisterShellHook) { (*g_RegisterShellHook)(0, RSH_REGISTER); if ((HIWORD(GetVersion())>>14) == W_VER_NT) (*g_RegisterShellHook)(_hwnd, RSH_REGISTER_TASKMAN); else (*g_RegisterShellHook)(_hwnd, RSH_REGISTER); } */ Refresh(); return 0; }
HWND LoadToolbar(HINSTANCE hInstance, WORD wToolBarName, HWND hParent) { HRSRC hFound; HGLOBAL hResource; HBITMAP hBitmap; HWND hToolbar; TB_DATA *pData; UINT *pIDs; TBBUTTON *pButtons; // find the resource if ((hFound = FindResource(hInstance, MAKEINTRESOURCE(wToolBarName), RT_TOOLBAR)) == NULL) { return NULL; } // load toolbar resource if ((hResource = LoadResource(hInstance, hFound)) == NULL) { return NULL; } // load toolbar resource if ((hBitmap =LoadBitmap(hInstance, MAKEINTRESOURCE(wToolBarName))) == NULL) { return NULL; } // lock resource pData = (TB_DATA*)LockResource(hResource); pIDs = pData->uIDs; pButtons = (TBBUTTON*)malloc(sizeof(TBBUTTON) * pData->uItemCount); int nBitmaps = 0; // create toolbar structure for (int i=0; i<pData->uItemCount; i++) { // special treatment if (pIDs[i] == 0) { pButtons[i].iString = 0; pButtons[i].iBitmap = 0; pButtons[i].fsStyle = TBSTYLE_SEP; } else { pButtons[i].iBitmap = nBitmaps; pButtons[i].iString = nBitmaps++; pButtons[i].fsStyle = TBSTYLE_BUTTON; } // common procedure pButtons[i].idCommand = pIDs[i]; pButtons[i].fsState = TBSTATE_ENABLED; pButtons[i].dwData = 0; } hToolbar = CreateToolbarEx(hParent, WS_VISIBLE | WS_BORDER | TBSTYLE_TOOLTIPS, wToolBarName, nBitmaps, NULL, (UINT)hBitmap, pButtons, pData->uItemCount, pData->uWidth + 2, pData->uHeight, pData->uWidth, pData->uHeight, sizeof(TBBUTTON)); free(pButtons); return hToolbar; }
static int icvCreateTrackbar( const char* trackbar_name, const char* window_name, int* val, int count, CvTrackbarCallback on_notify, CvTrackbarCallback2 on_notify2, void* userdata ) { int result = 0; CV_FUNCNAME( "icvCreateTrackbar" ); __BEGIN__; char slider_name[32]; CvWindow* window = 0; CvTrackbar* trackbar = 0; int pos = 0; if( !window_name || !trackbar_name ) CV_ERROR( CV_StsNullPtr, "NULL window or trackbar name" ); if( count <= 0 ) CV_ERROR( CV_StsOutOfRange, "Bad trackbar maximal value" ); window = icvFindWindowByName(window_name); if( !window ) EXIT; trackbar = icvFindTrackbarByName(window,trackbar_name); if( !trackbar ) { TBBUTTON tbs; ButtonInfo tbis; RECT rect; int bcount; int len = (int)strlen( trackbar_name ); // create toolbar if it is not created yet if( !window->toolbar.toolbar ) { const int default_height = 30; window->toolbar.toolbar = CreateToolbarEx( window->frame, WS_CHILD | CCS_TOP | TBSTYLE_WRAPABLE, 1, 0, 0, 0, 0, 0, 16, 20, 16, 16, sizeof(TBBUTTON)); GetClientRect(window->frame, &rect); MoveWindow( window->toolbar.toolbar, 0, 0, rect.right - rect.left, default_height, TRUE); SendMessage(window->toolbar.toolbar, TB_AUTOSIZE, 0, 0); ShowWindow(window->toolbar.toolbar, SW_SHOW); window->toolbar.first = 0; window->toolbar.pos = 0; window->toolbar.rows = 0; window->toolbar.toolBarProc = (WNDPROC)icvGetWindowLongPtr(window->toolbar.toolbar, CV_WNDPROC); icvUpdateWindowPos(window); // Subclassing from toolbar icvSetWindowLongPtr(window->toolbar.toolbar, CV_WNDPROC, HGToolbarProc); icvSetWindowLongPtr(window->toolbar.toolbar, CV_USERDATA, window); } /* Retrieve current buttons count */ bcount = (int)SendMessage(window->toolbar.toolbar, TB_BUTTONCOUNT, 0, 0); if(bcount > 1) { /* If this is not the first button then we need to separate it from the previous one */ tbs.iBitmap = 0; tbs.idCommand = bcount; // Set button id to it's number tbs.iString = 0; tbs.fsStyle = TBSTYLE_SEP; tbs.fsState = TBSTATE_ENABLED; SendMessage(window->toolbar.toolbar, TB_ADDBUTTONS, 1, (LPARAM)&tbs); // Retrieve current buttons count bcount = (int)SendMessage(window->toolbar.toolbar, TB_BUTTONCOUNT, 0, 0); } /* Add a button which we're going to cover with the slider */ tbs.iBitmap = 0; tbs.idCommand = bcount; // Set button id to it's number tbs.fsState = TBSTATE_ENABLED; #if 0/*!defined WIN64 && !defined EM64T*/ tbs.fsStyle = 0; tbs.iString = 0; #else #ifndef TBSTYLE_AUTOSIZE #define TBSTYLE_AUTOSIZE 0x0010 #endif #ifndef TBSTYLE_GROUP #define TBSTYLE_GROUP 0x0004 #endif //tbs.fsStyle = TBSTYLE_AUTOSIZE; tbs.fsStyle = TBSTYLE_GROUP; tbs.iString = (INT_PTR)trackbar_text; #endif SendMessage(window->toolbar.toolbar, TB_ADDBUTTONS, 1, (LPARAM)&tbs); /* Adjust button size to the slider */ tbis.cbSize = sizeof(tbis); tbis.dwMask = TBIF_SIZE; GetClientRect(window->hwnd, &rect); tbis.cx = (unsigned short)(rect.right - rect.left); SendMessage(window->toolbar.toolbar, TB_SETBUTTONINFO, (WPARAM)tbs.idCommand, (LPARAM)&tbis); /* Get button position */ SendMessage(window->toolbar.toolbar, TB_GETITEMRECT, (WPARAM)tbs.idCommand, (LPARAM)&rect); /* Create a slider */ trackbar = (CvTrackbar*)cvAlloc( sizeof(CvTrackbar) + len + 1 ); trackbar->signature = CV_TRACKBAR_MAGIC_VAL; trackbar->notify = 0; trackbar->notify2 = 0; trackbar->parent = window; trackbar->pos = 0; trackbar->data = 0; trackbar->id = bcount; trackbar->next = window->toolbar.first; trackbar->name = (char*)(trackbar + 1); memcpy( trackbar->name, trackbar_name, len + 1 ); window->toolbar.first = trackbar; sprintf(slider_name, "Trackbar%p", val); trackbar->hwnd = CreateWindowEx(0, TRACKBAR_CLASS, slider_name, WS_CHILD | WS_VISIBLE | TBS_AUTOTICKS | TBS_FIXEDLENGTH | TBS_HORZ | TBS_BOTTOM, rect.left + HG_BUDDY_WIDTH, rect.top, rect.right - rect.left - HG_BUDDY_WIDTH, rect.bottom - rect.top, window->toolbar.toolbar, (HMENU)(size_t)bcount, hg_hinstance, 0); sprintf(slider_name,"Buddy%p", val); trackbar->buddy = CreateWindowEx(0, "STATIC", slider_name, WS_CHILD | SS_RIGHT, rect.left, rect.top, HG_BUDDY_WIDTH, rect.bottom - rect.top, window->toolbar.toolbar, 0, hg_hinstance, 0); icvSetWindowLongPtr( trackbar->hwnd, CV_USERDATA, trackbar ); /* Minimize the number of rows */ SendMessage( window->toolbar.toolbar, TB_SETROWS, MAKEWPARAM(1, FALSE), (LPARAM)&rect ); } else { trackbar->data = 0; trackbar->notify = 0; trackbar->notify2 = 0; } trackbar->maxval = count; /* Adjust slider parameters */ SendMessage(trackbar->hwnd, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, count)); SendMessage(trackbar->hwnd, TBM_SETTICFREQ, (WPARAM)1, (LPARAM)0 ); if( val ) pos = *val; SendMessage(trackbar->hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)pos ); SendMessage(window->toolbar.toolbar, TB_AUTOSIZE, 0, 0); trackbar->pos = -1; icvUpdateTrackbar( trackbar, pos ); ShowWindow( trackbar->buddy, SW_SHOW ); ShowWindow( trackbar->hwnd, SW_SHOW ); trackbar->notify = on_notify; trackbar->notify2 = on_notify2; trackbar->userdata = userdata; trackbar->data = val; /* Resize the window to reflect the toolbar resizing*/ icvUpdateWindowPos(window); result = 1; __END__; return result; }
BOOL InitInstance(HANDLE hInstance, int nCmdShow) { g_hInst = (HINSTANCE)hInstance; OleInitialize(NULL); INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES | ICC_INTERNET_CLASSES | ICC_TAB_CLASSES; InitCommonControlsEx(&icex); g_hMainWnd = CreateWindowEx(0, _LOGIN_SERVER_CLASS, _LOGIN_SERVER_TITLE, WS_OVERLAPPEDWINDOW|WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, (HINSTANCE)hInstance, NULL); g_hToolBar = CreateToolbarEx(g_hMainWnd, WS_CHILD|CCS_TOP|WS_VISIBLE|WS_BORDER, _IDW_TOOLBAR, sizeof(tbButtons) / sizeof(TBBUTTON), (HINSTANCE)hInstance, IDB_TOOLBAR, (LPCTBBUTTON)&tbButtons, sizeof(tbButtons) / sizeof(TBBUTTON), _BMP_CX, _BMP_CY, _BMP_CX, _BMP_CY, sizeof(TBBUTTON)); RECT rcMainWnd, rcToolBar, rcStatusBar; GetClientRect(g_hMainWnd, &rcMainWnd); GetWindowRect(g_hToolBar, &rcToolBar); g_hStatusBar = CreateWindowEx(0L, STATUSCLASSNAME, _T(""), WS_CHILD|WS_BORDER|WS_VISIBLE|SBS_SIZEGRIP, 0, rcMainWnd.bottom - _STATUS_HEIGHT, (rcMainWnd.right - rcMainWnd.left), _STATUS_HEIGHT, g_hMainWnd, (HMENU)_IDW_STATUSBAR, g_hInst, NULL); int nStatusPartsWidths[_NUMOFMAX_STATUS_PARTS]; int nCnt = 0; for (int i = _NUMOFMAX_STATUS_PARTS - 1; i >= 0; i--) nStatusPartsWidths[nCnt++] = (rcMainWnd.right - rcMainWnd.left) - (90 * i); SendMessage(g_hStatusBar, SB_SETPARTS, _NUMOFMAX_STATUS_PARTS, (LPARAM)nStatusPartsWidths); SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(1, 0), (LPARAM)_TEXT("Not Connected")); GetWindowRect(g_hStatusBar, &rcStatusBar); g_hLogMsgWnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _TEXT(""), WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT|LVS_EDITLABELS, 0, (rcToolBar.bottom - rcToolBar.top) - 2, (rcMainWnd.right - rcMainWnd.left), (rcMainWnd.bottom - rcMainWnd.top) - (rcToolBar.bottom - rcToolBar.top) + 2 - (rcStatusBar.bottom - rcStatusBar.top), g_hMainWnd, NULL, (HINSTANCE)hInstance, NULL); ListView_SetExtendedListViewStyleEx(g_hLogMsgWnd, 0, LVS_EX_FULLROWSELECT); LV_COLUMN lvc; TCHAR szText[64]; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.cx = 100; lvc.pszText = szText; for (i = 0; i < 3; i++) { lvc.iSubItem = i; LoadString((HINSTANCE)hInstance, IDS_LVS_LABEL1 + i, szText, sizeof(szText)); ListView_InsertColumn(g_hLogMsgWnd, i, &lvc); } ListView_SetColumnWidth( g_hLogMsgWnd, 2, 500 ); SendMessage(g_hToolBar, TB_SETSTATE, (WPARAM)IDM_STOPSERVICE, (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0)); ShowWindow(g_hMainWnd, SW_SHOW); UpdateWindow(g_hMainWnd); if (WSAStartup(MAKEWORD(2, 2), &g_wsd) != 0) return (FALSE); GetDBManager()->Init( InsertLogMsg, "Mir2_Account", "sa", "prg" ); // BYTE btInstalled; if (!jRegGetKey(_LOGIN_SERVER_REGISTRY, _TEXT("Installed"), (LPBYTE)&btInstalled)) CreateConfigProperties(); InvalidateRect( g_hMainWnd, NULL, TRUE ); return TRUE; }
//------------------------------------------------------------------ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int cmdShow) { int i; HDC dc; MSG mesg; RECT rc; inst = hInstance; //DPIAware typedef BOOL(WINAPI *TGetProcAddress)(); TGetProcAddress getProcAddress = (TGetProcAddress)GetProcAddress(GetModuleHandle(_T("user32")), "SetProcessDPIAware"); if(getProcAddress) getProcAddress(); memset(custom, 200, sizeof(custom)); _tcscpy(pdfObject.fn, _T("sudoku.pdf")); pdfObject.pageWidth=595; pdfObject.pageHeight=842; pdfObject.count=6; pdfObject.countPerPage=6; pdfObject.border=40; pdfObject.spacing=20; readini(); //load common controls #if _WIN32_IE >= 0x0300 INITCOMMONCONTROLSEX iccs; iccs.dwSize= sizeof(INITCOMMONCONTROLSEX); iccs.dwICC= ICC_BAR_CLASSES; InitCommonControlsEx(&iccs); #else InitCommonControls(); #endif // create the main window WNDCLASS wc; ZeroMemory(&wc, sizeof(wc)); wc.lpfnWndProc = WndMainProc; wc.hInstance = inst; wc.lpszClassName = CLASSNAME; wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON)); if(!RegisterClass(&wc)){ #ifdef UNICODE msg("This version cannot run on Windows 95/98/ME."); #else msg("RegisterClass failed"); #endif return 2; } scrW= GetSystemMetrics(SM_CXSCREEN); scrH= GetSystemMetrics(SM_CYSCREEN); aminmax(mainLeft, 0, scrW-50); aminmax(mainTop, 0, scrH-50); hWin = CreateWindow(CLASSNAME, title, WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPCHILDREN, mainLeft, mainTop, mainW, mainH, 0, 0, inst, 0); if(!hWin){ msg("CreateWindow failed"); return 3; } haccel= LoadAccelerators(inst, MAKEINTRESOURCE(IDR_ACCELERATOR)); Naccel= CopyAcceleratorTable(haccel, accel, sizeA(accel)); initLang(); //create status bar statusbar= CreateStatusWindow(WS_CHILD, 0, hWin, 1); static int parts[]={100, 140, 210, 230, -1}; dc=GetDC(hWin); for(i=0; i<sizeA(parts)-1; i++){ parts[i]=parts[i]*GetDeviceCaps(dc, LOGPIXELSX)/96; } ReleaseDC(hWin, dc); SendMessage(statusbar, SB_SETPARTS, sizeA(parts), (LPARAM)parts); ShowWindow(statusbar, SW_SHOW); //create tool bar i=sizeA(tbb); for(TBBUTTON *u=tbb; u<endA(tbb); u++){ if(u->fsStyle==TBSTYLE_SEP) i--; } toolbar = CreateToolbarEx(hWin, WS_CHILD|TBSTYLE_TOOLTIPS, 2, i, inst, IDB_TOOLBAR, tbb, sizeA(tbb), 16, 16, 16, 15, sizeof(TBBUTTON)); GetClientRect(toolbar, &rc); MapWindowPoints(toolbar, hWin, (POINT*)&rc, 2); toolH= rc.bottom; if(toolBarVisible) ShowWindow(toolbar, SW_SHOW); langChanged(); ShowWindow(hWin, cmdShow); initSquare(false); UpdateWindow(hWin); toolBitmap(); numButtons(); while(GetMessage(&mesg, NULL, 0, 0)==TRUE){ if(!TranslateAccelerator(hWin, haccel, &mesg)){ TranslateMessage(&mesg); DispatchMessage(&mesg); } } if(delreg) deleteini(HKEY_CURRENT_USER); return 0; }
// // FUNCTION: InitInstance(HINSTANCE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { hInst = hInstance; // Store instance handle in our global variable HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_MAXIMIZEBOX| WS_MINIMIZEBOX| WS_SYSMENU, 0, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); if (!hWnd) { return FALSE; } INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwICC = ICC_BAR_CLASSES; InitCommonControlsEx(&InitCtrlEx); TBBUTTON tbrButtons[10]; tbrButtons[0].iBitmap = 0; tbrButtons[0].idCommand = ID_FILE_OPEN; tbrButtons[0].fsState = TBSTATE_ENABLED; tbrButtons[0].fsStyle = TBSTYLE_BUTTON; tbrButtons[0].dwData = 0L; tbrButtons[0].iBitmap = 0; tbrButtons[0].iString = 0; tbrButtons[1].iBitmap = 1; tbrButtons[1].idCommand = ID_FILE_SAVE; tbrButtons[1].fsState = TBSTATE_ENABLED; tbrButtons[1].fsStyle = TBSTYLE_BUTTON; tbrButtons[1].dwData = 0L; tbrButtons[1].iString = 0; tbrButtons[2].iBitmap = 0; tbrButtons[2].idCommand =0; tbrButtons[2].fsState = TBSTATE_ENABLED; tbrButtons[2].fsStyle = TBSTYLE_SEP; tbrButtons[2].dwData = 0L; tbrButtons[2].iString = 0; tbrButtons[3].iBitmap = 2; tbrButtons[3].idCommand = ID_FORMAT_COLOR; tbrButtons[3].fsState = TBSTATE_ENABLED; tbrButtons[3].fsStyle = TBSTYLE_BUTTON; tbrButtons[3].dwData = 0L; tbrButtons[3].iString = 0; tbrButtons[4].iBitmap = 3; tbrButtons[4].idCommand = ID_SHAPE_SQUARE; tbrButtons[4].fsState = TBSTATE_ENABLED; tbrButtons[4].fsStyle = TBSTYLE_BUTTON; tbrButtons[4].dwData = 0L; tbrButtons[4].iString = 0; tbrButtons[5].iBitmap = 4; tbrButtons[5].idCommand = ID_SHAPE_ROUND; tbrButtons[5].fsState = TBSTATE_ENABLED; tbrButtons[5].fsStyle = TBSTYLE_BUTTON; tbrButtons[5].dwData = 0L; tbrButtons[5].iString = 0; tbrButtons[6].iBitmap = 5; tbrButtons[6].idCommand = ID_LINE_STRAIGHTLINE; tbrButtons[6].fsState = TBSTATE_ENABLED; tbrButtons[6].fsStyle = TBSTYLE_BUTTON; tbrButtons[6].dwData = 0L; tbrButtons[6].iString = 0; tbrButtons[7].iBitmap = 6; tbrButtons[7].idCommand = ID_SHAPE_ELLIPSE; tbrButtons[7].fsState = TBSTATE_ENABLED; tbrButtons[7].fsStyle = TBSTYLE_BUTTON; tbrButtons[7].dwData = 0L; tbrButtons[7].iString = 0; tbrButtons[8].iBitmap = 7; tbrButtons[8].idCommand = ID_SHAPE_RECTANGLE; tbrButtons[8].fsState = TBSTATE_ENABLED; tbrButtons[8].fsStyle = TBSTYLE_BUTTON; tbrButtons[8].dwData = 0L; tbrButtons[8].iString = 0; tbrButtons[9].iBitmap = 8; tbrButtons[9].idCommand = ID_LINE_FREESTYLE; tbrButtons[9].fsState = TBSTATE_ENABLED; tbrButtons[9].fsStyle = TBSTYLE_BUTTON; tbrButtons[9].dwData = 0L; tbrButtons[9].iString = 0; HWND hWndToolbar; hWndToolbar = CreateToolbarEx(hWnd, WS_VISIBLE | WS_CHILD | WS_BORDER, IDB_BITMAP1, NUMBUTTONS, hInst, IDB_BITMAP1, tbrButtons, NUMBUTTONS, 16, 16, 16, 16, sizeof(TBBUTTON)); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; }
BOOL InitInstance(HANDLE hInstance, int nCmdShow) { g_hInst = (HINSTANCE)hInstance; OleInitialize(NULL); INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES | ICC_INTERNET_CLASSES; InitCommonControlsEx(&icex); g_hMainWnd = CreateWindowEx(0, _GAME_SERVER_CLASS, _GAME_SERVER_TITLE, WS_OVERLAPPEDWINDOW|WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, (HINSTANCE)hInstance, NULL); g_hToolBar = CreateToolbarEx(g_hMainWnd, WS_CHILD|CCS_TOP|WS_VISIBLE|WS_BORDER, _IDW_TOOLBAR, sizeof(tbButtons) / sizeof(TBBUTTON), (HINSTANCE)hInstance, IDB_TOOLBAR, (LPCTBBUTTON)&tbButtons, sizeof(tbButtons) / sizeof(TBBUTTON), _BMP_CX, _BMP_CY, _BMP_CX, _BMP_CY, sizeof(TBBUTTON)); RECT rcMainWnd, rcToolBar, rcStatusBar; GetClientRect(g_hMainWnd, &rcMainWnd); GetWindowRect(g_hToolBar, &rcToolBar); g_hStatusBar = CreateWindowEx(0L, STATUSCLASSNAME, _TEXT(""), WS_CHILD|WS_BORDER|WS_VISIBLE|SBS_SIZEGRIP, 0, rcMainWnd.bottom - _STATUS_HEIGHT, (rcMainWnd.right - rcMainWnd.left), _STATUS_HEIGHT, g_hMainWnd, (HMENU)_IDW_STATUSBAR, g_hInst, NULL); int nStatusPartsWidths[_NUMOFMAX_STATUS_PARTS]; int nCnt = 0; for (int i = _NUMOFMAX_STATUS_PARTS - 1; i >= 0; i--) nStatusPartsWidths[nCnt++] = (rcMainWnd.right - rcMainWnd.left) - (90 * i); SendMessage(g_hStatusBar, SB_SETPARTS, _NUMOFMAX_STATUS_PARTS, (LPARAM)nStatusPartsWidths); GetWindowRect(g_hStatusBar, &rcStatusBar); g_hLogMsgWnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _TEXT(""), WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT|LVS_EDITLABELS, 0, (rcToolBar.bottom - rcToolBar.top), (rcMainWnd.right - rcMainWnd.left), (rcMainWnd.bottom - rcMainWnd.top) - (rcToolBar.bottom - rcToolBar.top) - (rcStatusBar.bottom - rcStatusBar.top), g_hMainWnd, NULL, (HINSTANCE)hInstance, NULL); ListView_SetExtendedListViewStyleEx(g_hLogMsgWnd, 0, LVS_EX_FULLROWSELECT); LV_COLUMN lvc; TCHAR szText[64]; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.cx = 150; lvc.pszText = szText; for (i = 0; i < 3; i++) { lvc.iSubItem = i; LoadString((HINSTANCE)hInstance, IDS_LVS_LABEL1 + i, szText, sizeof(szText)/sizeof(TCHAR)); ListView_InsertColumn(g_hLogMsgWnd, i, &lvc); } OrgLogMsgWndProc = (WNDPROC)SetWindowLong(g_hLogMsgWnd, GWL_WNDPROC, (LONG)LogMsgWndProc); SendMessage(g_hToolBar, TB_SETSTATE, (WPARAM)IDM_STOPSERVICE, (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0)); ShowWindow(g_hMainWnd, SW_SHOW); UpdateWindow(g_hMainWnd); if (WSAStartup(MAKEWORD(2, 2), &g_wsd) != 0) return (FALSE); srand((unsigned)time(NULL)); BYTE btInstalled; if (!jRegGetKey(_GAME_SERVER_REGISTRY, _TEXT("Installed"), (LPBYTE)&btInstalled)) DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CONFIGDLG), NULL, (DLGPROC)ConfigDlgFunc); TCHAR wszDatabase[256]; char szDatabase[256]; jRegGetKey(_GAME_SERVER_REGISTRY, _TEXT("Device"), (LPBYTE)wszDatabase); WideCharToMultiByte(CP_ACP, 0, wszDatabase, -1, szDatabase, sizeof(szDatabase), NULL, NULL); g_MirDB.SetDiagRec( __cbDBMsg ); g_MirDB.Init(); g_pConnCommon = g_MirDB.CreateConnection( "Mir2_Common", "sa", "prg" ); g_pConnGame = g_MirDB.CreateConnection( szDatabase, "sa", "prg" ); return TRUE; }
bool CApp::InitInstance(int nCmdShow) { DbgLog((LOG_TRACE, 5, TEXT("CApp::InitInstance()"))) ; // Win32 will always set hPrevInstance to NULL, so check // things a little closer. This is because we only want a single // version of this app to run at a time. m_hWnd = FindWindow(m_szAppName, m_szAppTitle) ; if(m_hWnd) { // We found another instance of ourself. Lets use that one: if(IsIconic(m_hWnd)) { ShowWindow(m_hWnd, SW_RESTORE); } SetForegroundWindow(m_hWnd); // If this app actually had any methodality, we would // also want to communicate any action that our 'twin' // should now perform based on how the user tried to // execute us. return false; } // Register the app main window class WNDCLASSEX wc ; wc.cbSize = sizeof(wc) ; wc.style = CS_HREDRAW | CS_VREDRAW ; wc.lpfnWndProc = (WNDPROC) WndProc ; wc.cbClsExtra = 0 ; wc.cbWndExtra = 0 ; wc.hInstance = m_hInstance ; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW) ; wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1) ; wc.lpszMenuName = TEXT("DvdSample_Menu"); wc.lpszClassName = m_szAppName ; wc.hIconSm = NULL ; if(0 == RegisterClassEx(&wc)) { DbgLog((LOG_ERROR, 0, TEXT("ERROR: RegisterClassEx() for app class failed (Error %ld)"), GetLastError())) ; return false ; } // Determine where to put the Application Window RECT rDesktop; SystemParametersInfo(SPI_GETWORKAREA, NULL, &rDesktop, NULL); // Create an instance of the window we just registered // locate it at the bottom of the screen (bottom of screen - height of player) m_hWnd = CreateWindowEx(0, m_szAppName, m_szAppTitle, WS_OVERLAPPEDWINDOW, //& ~WS_THICKFRAME, 160, rDesktop.bottom - 150, 300, 150, NULL, NULL, m_hInstance, NULL); if(!m_hWnd) { DbgLog((LOG_ERROR, 0, TEXT("ERROR: CreateWindowEx() failed (Error %ld)"), GetLastError())) ; return false ; } // We now create the toolbar INITCOMMONCONTROLSEX cc; cc.dwSize = sizeof(INITCOMMONCONTROLSEX); cc.dwICC = ICC_BAR_CLASSES; // register only the toolbar control InitCommonControlsEx(&cc); #ifdef _WIN64 // BYTE bReserved[6] // padding for alignment #define PAD 0,0,0,0,0,0, 0,0, #elif defined(_WIN32) // BYTE bReserved[2] // padding for alignment #define PAD 0,0, 0,0, #endif // Configure toolbar buttons TBBUTTON tbb[] = { 0, ID_PLAYBACK_PREVIOUSCHAPTER, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD 1, ID_PLAYBACK_REWIND, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD 2, ID_PLAYBACK_PAUSE, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD 3, ID_PLAYBACK_PLAY, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD 4, ID_PLAYBACK_STOP, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD 5, ID_PLAYBACK_FASTFORWARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD 6, ID_PLAYBACK_NEXTCHAPTER, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD 9, 0, TBSTATE_ENABLED, TBSTYLE_SEP, PAD 7, ID_PLAYBACK_MENUROOT, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD 8, ID_OPTIONS_FULLSCREEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD 9, ID_PLAYBACK_STEPFORWARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD }; m_hwndToolBar = CreateToolbarEx(m_hWnd, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | CCS_TOP | TBSTYLE_TOOLTIPS, 1, 10, m_hInstance, IDR_TOOLBAR1, tbb, 11, 0, 0, 0, 0, sizeof(TBBUTTON)); if(!m_hwndToolBar) { DbgLog((LOG_ERROR, 0, TEXT("ERROR: CreateToolbarEx() failed (Error %ld)"), GetLastError())) ; return false ; } // we now set up the dvd playback class m_pDvdCore = new CDvdCore(m_hInstance, this); if(!m_pDvdCore->Init()) { DbgLog((LOG_ERROR, 0, TEXT("ERROR: CDvdCore::Init() failed"))) ; return false; } m_pDvdCore->SetVideoWindowTitle(TEXT("DvdSample Video Window")); // and finally, we make the window visible ShowWindow(m_hWnd, nCmdShow); UpdateWindow(m_hWnd) ; return true; }
/*****************************Private*Routine******************************\ * VideoCd_OnCreate * \**************************************************************************/ BOOL VideoCd_OnCreate( HWND hwnd, LPCREATESTRUCT lpCreateStruct ) { RECT rc; int Pane[2]; InitCommonControls(); /* ** Create the toolbar and statusbar. */ g_hwndToolbar = CreateToolbarEx(hwnd, WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS | CCS_NODIVIDER, ID_TOOLBAR, NUMBER_OF_BITMAPS, hInst, IDR_TOOLBAR, tbButtons, DEFAULT_TBAR_SIZE, dxBitmap, dyBitmap, dxBitmap, dyBitmap, sizeof(TBBUTTON)); if(g_hwndToolbar == NULL) { return FALSE; } g_hwndStatusbar = CreateStatusWindow(WS_VISIBLE | WS_CHILD | CCS_BOTTOM, TEXT("Example Text"), hwnd, ID_STATUSBAR); GetWindowRect(g_hwndToolbar, &rc); dyToolbar = rc.bottom - rc.top; GetWindowRect(g_hwndStatusbar, &rc); dyStatusbar = rc.bottom - rc.top; dyTrackbar = 30; GetClientRect(hwnd, &rc); Pane[0] = (rc.right - rc.left) / 2 ; Pane[1] = -1; SendMessage(g_hwndStatusbar, SB_SETPARTS, 2, (LPARAM)Pane); g_hwndTrackbar = CreateWindowEx(0, TRACKBAR_CLASS, TEXT("Trackbar Control"), WS_CHILD | WS_VISIBLE | TBS_AUTOTICKS | TBS_ENABLESELRANGE, LEFT_MARGIN, dyToolbar - 1, (rc.right - rc.left) - (2* LEFT_MARGIN), dyTrackbar, hwnd, (HMENU)ID_TRACKBAR, hInst, NULL); SetDurationLength((REFTIME)0); SetCurrentPosition((REFTIME)0); SetTimer(hwnd, StatusTimer, 100, NULL); if(g_hwndStatusbar == NULL || g_hwndTrackbar == NULL) { return FALSE; } return TRUE; }