voidCmfcmovewindowdlg::onbnclickedbutton1 () {// LeftCRect Rec; GetWindowRect (&rec); Rec.left-=M_imove; Rec.right-=M_imove; MoveWindow (&rec); }voidCmfcmovewindowdlg::onbnclickedbutton3 () {// RightCRect Rec; GetWindowRect (&rec); Rec.left+=M_imove; Rec.right+=M_imove; MoveWindow (&rec); }voidCmfcmovewindowdlg::onbnclickedbutton2 () {// upCRect Rec; GetWindowRect (&rec); Rec.top-=M_imove; Rec.bottom-=M_imove; MoveWindow (&rec); }voidCmfcmovewindowdlg::onbnclickedbutton4 () {// DownCRect Rec; GetWindowRect (&rec); Rec.top+=M_imove; Rec.bottom+=M_imove; MoveWindow (&rec); }voidcmfcmovewindowdlg::onenchangeedit1 () {//TODO: If the control is a RICHEDIT control, it will not//send this notification unless overriding CDialog::OnInitDialog ()//function and call CRichEditCtrl (). SetEventMask (),//The enm_change flag "or" is also calculated into the mask. M_imove=Getdlgitemint (IDC_EDIT1);}voidcmfcmovewindowdlg::onbnclickedbutton5 () {if(!M_btopwindow) {:: SetWindowPos (M_hwnd, Hwnd_topmost,0,0,0,0, Swp_nomove|swp_nosize); Setdlgitemtext (Idc_button5,"Cancel"); } Else{:: SetWindowPos (M_hwnd, Hwnd_notopmost,0,0,0,0, Swp_nomove|swp_nosize); Setdlgitemtext (Idc_button5,"Settopwindow"); } M_btopwindow= !M_btopwindow;}
voidCmfcmovewindowdlg::onbnclickedbutton6 () {if(!m_bcreate) {M_bcreate= !m_bcreate; M_dlgshow.create (Idd_dialog1, NULL); } m_dlgshow.showwindow (Sw_show);}//SubDlg.cppBOOL Cdiashow::oninitdialog () {cdialog::oninitdialog (); //Get Desktop sizeCRect Rectworkarea; SystemParametersInfo (Spi_getworkarea,0, &Rectworkarea, Spif_sendchange); //Get dialog box sizeCRect Rectdlg; GetWindowRect (&Rectdlg); //Set the window to the lower-right corner:: SetWindowPos (M_hwnd, Hwnd_bottom, Rectworkarea.right-rectdlg.width (), Rectworkarea.bottom-rectdlg.height (), Rectdlg.width (), Rectdlg.height (), swp_nozorder); //Floating Effect:: AnimateWindow (M_hwnd, +, aw_ver_negative|aw_slide); returnTRUE;//return TRUE Unless you set the focus to a control//Exception: OCX property page should return FALSE}
MFC window move, top, floating effect