/* * SetScrProc - processes messages for the Data Control Dialog */ WINEXPORT BOOL CALLBACK SetScrProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { case WM_INITDIALOG: CenterWindowInRoot( hwndDlg ); globalTodlgData(); ctl_dlg_init( GET_HINSTANCE( hwndDlg ), hwndDlg, &dlgData, &Ctl_setscr ); return( TRUE ); case WM_COMMAND: switch( LOWORD( wParam ) ) { case SETSCR_DEFAULTS: setdlgDataDefaults(); ctl_dlg_reset( GET_HINSTANCE( hwndDlg ), hwndDlg, &dlgData, &Ctl_setscr, TRUE ); return( TRUE ); case IDOK: if( !ctl_dlg_done( GET_HINSTANCE( hwndDlg ), hwndDlg, &dlgData, &Ctl_setscr ) ) { return( TRUE ); } dlgDataToGlobal(); // fall through case IDCANCEL: EndDialog( hwndDlg, TRUE ); return( TRUE ); } ctl_dlg_process( &Ctl_setscr, wParam, lParam ); } return( FALSE ); }
void add_button( HWND parent, int top, int left, int id, int FAR * pwidth, int FAR * pheight ) { HWND hbutton; HINSTANCE inst; // Note that the resource ID is the same as the control ID inst = GET_HINSTANCE( parent ); button_size( parent, id, pwidth, pheight ); hbutton = CreateWindow( "BUTTON", NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, // Window style left, // horizontal top, // vertical *pwidth, // width *pheight, // height parent, // parent window (HMENU)id, // menu is really child number inst, // This instance owns this window. NULL // Pointer not needed. ); }
/* * GetSaveFName - let the user select a file name for a save operation * fname must point to a buffer of length at least _MAX_PATH */ BOOL GetSaveFName( HWND mainhwnd, char *fname ) { static char filterList[] = "File (*.*)" \ "\0" \ "*.*" \ "\0\0"; OPENFILENAME of; int rc; fname[0] = 0; memset( &of, 0, sizeof( OPENFILENAME ) ); of.lStructSize = sizeof( OPENFILENAME ); of.hwndOwner = mainhwnd; of.lpstrFilter = (LPSTR)filterList; of.lpstrDefExt = ""; of.nFilterIndex = 1L; of.lpstrFile = fname; of.nMaxFile = _MAX_PATH; of.lpstrTitle = NULL; of.Flags = OFN_HIDEREADONLY; #ifndef NOUSE3D of.Flags |= OFN_ENABLEHOOK; of.lpfnHook = (LPOFNHOOKPROC)MakeOpenFileHookProcInstance( LBSaveHook, GET_HINSTANCE( mainhwnd ) ); #endif rc = GetSaveFileName( &of ); #ifndef NOUSE3D FreeProcInstance( (FARPROC)of.lpfnHook ); #endif return( rc ); } /* GetSaveFName */
static void button_size( HWND hwnd, int id, int FAR * pwidth, int FAR * pheight ) { HINSTANCE inst; HBITMAP bmp; BITMAP bitmap; inst = GET_HINSTANCE( hwnd ); bmp = LoadBitmap( inst, MAKEINTRESOURCE( id ) ); if( !bmp ) return; GetObject( bmp, sizeof(BITMAP), &bitmap ); *pwidth = bitmap.bmWidth +5; *pheight = bitmap.bmHeight + 5; DeleteObject( bmp ); }
/* * SetGenProc - processes messages for the Data Control Dialog */ BOOL WINEXP SetGenProc( HWND hwndDlg, unsigned msg, UINT wParam, LONG lParam ) { switch( msg ) { case WM_INITDIALOG: CenterWindowInRoot( hwndDlg ); globalTodlgData(); ctl_dlg_init( GET_HINSTANCE( hwndDlg ), hwndDlg, &dlgData, &Ctl_setgen ); dyn_tpl_init( &Dyn_setgen, hwndDlg ); return( TRUE ); case WM_COMMAND: switch( LOWORD( wParam ) ) { case SETGEN_DEFAULTS: setdlgDataDefaults(); ctl_dlg_reset( GET_HINSTANCE( hwndDlg ), hwndDlg, &dlgData, &Ctl_setgen, TRUE ); dyn_tpl_init( &Dyn_setgen, hwndDlg ); return( TRUE ); case IDOK: if( !ctl_dlg_done( GET_HINSTANCE( hwndDlg ), hwndDlg, &dlgData, &Ctl_setgen ) ) { return( TRUE ); } dlgDataToGlobal(); // fall through case IDCANCEL: EndDialog( hwndDlg, TRUE ); return( TRUE ); } ctl_dlg_process( &Ctl_setgen, wParam, lParam ); dyn_tpl_process( &Dyn_setgen, hwndDlg, wParam, lParam ); } return( FALSE ); }
int GetNewFiles( WWindow *parent, WString *results, const char *caption, const char *filters, const char *tgt_file ) { HWND owner; HINSTANCE hinst; GetFilesInfo info; // this is a grody kludge to get an HWND from a gui_window // it assumes that the HWND is the first field in the gui_window structure owner = *( (HWND *)(parent->handle() ) ); hinst = (HINSTANCE)GET_HINSTANCE( owner ); info.result = results; info.tgt_file = tgt_file; return( fileSelectDlg( hinst, owner, &info, caption, filters ) ); }
/* * snoopDlgProc - callback routine for snoop dialog */ WINEXPORT BOOL CALLBACK SnoopDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { // int i; int cmd; int index; char snoop[MAX_INPUT_LINE]; #ifdef __NT__ BROWSEINFO bi; char buffer1[MAX_PATH]; char buffer2[MAX_PATH]; LPITEMIDLIST pidl; #endif #ifdef __NT__ lparam = lparam; #endif switch( msg ) { case WM_INITDIALOG: CenterWindowInRoot( hwnd ); CheckDlgButton( hwnd, SNOOP_IGNORE_CASE, ( snoopData.case_ignore ) ? BST_CHECKED : BST_UNCHECKED ); CheckDlgButton( hwnd, SNOOP_REGULAR_EXPRESSIONS, ( snoopData.use_regexp ) ? BST_CHECKED : BST_UNCHECKED ); SetDlgItemText( hwnd, SNOOP_STRING, snoopData.find ); SetDlgItemText( hwnd, SNOOP_PATH, snoopData.path ); // default extsion should be grep extension SetDlgItemText( hwnd, SNOOP_EXT, snoopData.ext ); // this isn't quite right. but it's close. /* for( i = 0; i < extension.max; i++ ) { SendDlgItemMessage( hwnd, SNOOP_LISTBOX, LB_ADDSTRING, 0, (LPARAM)extension[i] ); } */ return( TRUE ); case WM_CLOSE: PostMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( IDCANCEL, 0, 0 ) ); return( TRUE ); case WM_COMMAND: switch( LOWORD( wparam ) ) { case SNOOP_EXT: cmd = GET_WM_COMMAND_CMD( wparam, lparam ); if( cmd == LBN_SELCHANGE || cmd == LBN_DBLCLK ) { index = (int)SendDlgItemMessage( hwnd, SNOOP_EXT, LB_GETCURSEL, 0, 0L ); if( index == LB_ERR ) { break; } SendDlgItemMessage( hwnd, SNOOP_EXT, LB_GETTEXT, index, (LPARAM)snoop ); SetDlgItemText( hwnd, SNOOP_STRING, snoop ); } break; #ifdef __NT__ case SNOOP_BROWSE: bi.hwndOwner = hwnd; bi.pidlRoot = NULL; bi.pszDisplayName = NULL; LoadString( GET_HINSTANCE( hwnd ), VI_BROWSE_MSG, buffer1, sizeof( buffer1 ) ); bi.lpszTitle = buffer1; bi.ulFlags = BIF_RETURNONLYFSDIRS; bi.lpfn = BrowseCallbackProc; GetDlgItemText( hwnd, SNOOP_PATH, buffer2, MAX_PATH ); bi.lParam = (LPARAM)buffer2; if( (pidl = pfnSHBrowseForFolder( &bi )) != NULL ) { if( pfnSHGetPathFromIDList( pidl, buffer1 ) ) { SetDlgItemText( hwnd, SNOOP_PATH, buffer1 ); } } break; #endif case IDCANCEL: // RemoveEditSubClass( hwnd, SNOOP_STRING ); EndDialog( hwnd, FALSE ); break; case IDOK: GetDlgItemText( hwnd, SNOOP_STRING, snoop, MAX_INPUT_LINE ); ReplaceString( &snoopData.find, snoop ); GetDlgItemText( hwnd, SNOOP_EXT, snoop, MAX_INPUT_LINE ); ReplaceString( &snoopData.ext, snoop ); GetDlgItemText( hwnd, SNOOP_PATH, snoop, MAX_INPUT_LINE ); ReplaceString( &snoopData.path, snoop ); snoopData.case_ignore = IsDlgButtonChecked( hwnd, SNOOP_IGNORE_CASE ); snoopData.use_regexp = IsDlgButtonChecked( hwnd, SNOOP_REGULAR_EXPRESSIONS ); // RemoveEditSubClass( hwnd, SNOOP_STRING ); EndDialog( hwnd, TRUE ); break; default: return( FALSE ); } // hand it off to fgrep return( TRUE ); } return( FALSE ); } /* SnoopDlgProc */
void draw_button( int button_id, DRAWITEMSTRUCT FAR * draw ) { HBITMAP bmp; HBITMAP oldbmp; HPEN blackpen, shadowpen, brightpen, facepen; HPEN oldpen; BITMAP bitmap; HDC memdc; HINSTANCE inst; int shift; inst = GET_HINSTANCE( draw->hwndItem ); bmp = LoadBitmap( inst, MAKEINTRESOURCE( button_id ) ); if( !bmp ) return; GetObject( bmp, sizeof(BITMAP), &bitmap ); memdc = CreateCompatibleDC( draw->hDC ); oldbmp = SelectObject( memdc, bmp ); if( draw->itemState & ODS_SELECTED ) { shift = 4; } else { shift = 2; } BitBlt( draw->hDC, draw->rcItem.left + shift, draw->rcItem.top + shift, bitmap.bmWidth, bitmap.bmHeight, memdc, 0, 0, SRCCOPY ); SelectObject( memdc, oldbmp ); DeleteDC( memdc ); DeleteObject( bmp ); // Draw four sides of the button except one pixel in each corner blackpen = CreatePen( PS_SOLID, 0, RGB(0,0,0) ); brightpen = CreatePen( PS_SOLID, 0, RGB(255,255,255) ); shadowpen = CreatePen( PS_SOLID, 0, GetSysColor( COLOR_BTNSHADOW ) ); facepen = CreatePen( PS_SOLID, 0, GetSysColor( COLOR_BTNFACE ) ); oldpen = SelectObject( draw->hDC, blackpen ); horizontal( draw, draw->rcItem.top ); horizontal( draw, draw->rcItem.bottom - 1 ); vertical( draw, draw->rcItem.left ); vertical( draw, draw->rcItem.right - 1 ); // Now the shading SelectObject( draw->hDC, shadowpen ); if( draw->itemState & ODS_SELECTED ) { horizontal( draw, draw->rcItem.top + 1 ); vertical( draw, draw->rcItem.left + 1 ); SelectObject( draw->hDC, facepen ); horizontal( draw, draw->rcItem.top + 2 ); vertical( draw, draw->rcItem.left + 2 ); horizontal( draw, draw->rcItem.top + 3 ); vertical( draw, draw->rcItem.left + 3 ); } else { horizontal( draw, draw->rcItem.bottom - 2 ); horizontal( draw, draw->rcItem.bottom - 3 ); vertical( draw, draw->rcItem.right - 2 ); vertical( draw, draw->rcItem.right - 3 ); SelectObject( draw->hDC, brightpen ); horizontal( draw, draw->rcItem.top + 1 ); vertical( draw, draw->rcItem.left + 1 ); } SelectObject( draw->hDC, oldpen ); DeleteObject( blackpen ); DeleteObject( brightpen ); DeleteObject( shadowpen ); DeleteObject( facepen ); }