界面(1):对话框和菜单 打印和按钮等杂项
Q | 请教高手,图形对话框的问题 |
T | 我做了一个图象的界面,对话框的,在OnPaint中 画上背景图案,然后用Invalidate 方法刷新每个控件,但是控件并没有完全显示出来,特别是CCtrlList 等控件,滚动条有时候显示不出来,CEdit控件边上的3d效果也出不来,这是怎么了?哪位大虾指点指点! |
A |
class AFX_EXT_CLASS CBackgroundManager { public: CBackgroundManager(); virtual ~CBackgroundManager(); enum BackgroundLocation CBackgroundManager::CBackgroundManager() CBackgroundManager::~CBackgroundManager() } if (color != (COLORREF)-1) if (bRepaint && m_pWnd->GetSafeHwnd () != NULL) m_hBkgrBitmap = hBitmap; if (hBitmap != NULL) m_sizeBkgrBitmap = CSize (bmp.bmWidth, bmp.bmHeight); if (bRepaint && m_pWnd->GetSafeHwnd () != NULL) if (uiBmpResId != 0) SetBackgroundImage (hBitmap, location, TRUE /* Autodestroy */, bRepaint); ASSERT_VALID (pDC); CRect rectClient; if (m_BkgrLocation != BACKGR_TILE || m_hBkgrBitmap == NULL) if (m_hBkgrBitmap == NULL) ASSERT (m_sizeBkgrBitmap != CSize (0, 0)); if (m_BkgrLocation != BACKGR_TILE) switch (m_BkgrLocation) case BACKGR_TOPRIGHT: case BACKGR_BOTTOMLEFT: case BACKGR_BOTTOMRIGHT: pDC->DrawState (ptImage, m_sizeBkgrBitmap, m_hBkgrBitmap, DSS_NORMAL); return TRUE; cann HandleOnEraseBackground when handling WM_ERASEBKGND |
Q | 菜单是在哪里换的? |
T | |
A |
在子框架激活的时候替换的,去看MFC源代码
CDocument has a vertual method to return the default menu handle MSDN How to Use Multiple Menus in MFC App That Uses GetDefaultMenu http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B145857 错了,还有CDocTemplate |
Q | 如何作类似于ACDSee那样的缩略图显示. |
T | 如何作类似于ACDSee那样的缩略图显示. |
A |
BEGIN_MESSAGE_MAP(CImagePage, CPropertyPage) ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST_PREVIEW, OnCustomDraw) END_MESSAGE_MAP() void CImagePage::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) |
Q | 对话框resize时,如何保证其有一个最小的rect范围?。。。。。。 |
T |
2)再就是无模式对话框在ModifyStyleEx(0, WS_EX_TOOLWINDOW);后,其标题条变窄了,而且下面有一窄条,随机出现客户区一部分位图的图像,是怎么回事? --------------------------------------- 3)还是resize的问题,里面有一个list,几个btn,当resize时,如果list的rect消失了,那再放大时,其下面的btn就被覆盖(一部分显示,一部分不显示);如果resize过程中,list不消失,则一切正常,不知道为什么? |
A |
1 WM_GETMINMAXINFO 2 默认行为 3 默认行为 没有加消息映射的问题,去加一个到其他不是对话框的窗口,把消息映射复制过来 |
Q | 为什么编辑框中ctrl+c / ctrl+v没法用? |
T | 我在一个单文档的程序中使用了ie风格的工具栏(IDR_MAINFRAME),上面布置了多个编辑控件,可是发现没办法使用ctrl+c和ctrl+v。具体来说,就是在下面的view区中copy了一段文字,想paste到上面的编辑框,但是按了这个快捷键后,却粘贴到view区中去了。为什么不能粘贴到我光标所在的编辑框中呢?我的view是从richeditview中继承过来的。请各位大侠指点,分不够可以另开贴加分。 |
A |
Knowledge Base Q145616 HOWTO: How to Enable Edit Menu Commands for Edit Controls On a CDialog or other window that has no edit menu options for cutting, copying, and pasting, CEdit controls handle these functions through the normal Windows accelerator processing (CTRL+X,V,C, or the SHIFT-DELETE, SHIFT-INSERT, CTRL-INSERT, CTRL-DELETE, and so on keys). However, in a typical MDI or SDI application, these options are disabled. This is due to the default implementation for menu handlers and accelerator keys that AppWizard adds to your application to handle these functions. These menu handlers get the accelerator keystrokes instead of your edit control. This article shows you how to implement the edit control's clipboard functions on a CFormView-derived form |
Q | 请教,如何实现多行文本在一个指定RECT内的绘制? |
T | 向各位高手请教,如何实现多行文本在一个指定RECT内的绘制,并能够实现文本在水平及垂直方向上的对齐? |
A |
http://search.csdn.net/expert/topic/50/5001/2002/1/10/469317.htm
void CFlxRptText::Draw(Gdiplus::Graphics* pGraphics,CDrawContext* pDrawContext,CFlexReportView* pView) if(bstrFontName==_bstr_t("Default")||pFontText->GetLastStatus()!=Gdiplus::Ok){ nLineStyle[Border_Top]=GetAttributeLong("TopLineStyle"); ptStart[Border_Top].X=position.left; for(int j=0;j<Border_Max;j++){ } Command what is yours http://www.csdn.net/develop/author/netauthor/jiangsheng/ |
Q | 高分求解,与打印有关。。多谢 |
T |
本人在开发虚似打印机时,遇到一个问题,要大家帮忙先谢一下: 本人的打印是从win2kddk的OEMDLL下面的oemuni下面的例子改编过来的 问题是: 而黑色就成了白色, 所以当打印表格(是黑边框时就打不出来,但黑文字能打出来)不知何解。。 多谢。。 |
A | http://blog.joycode.com/jiangsheng/posts/3579.aspx |
Q | 多个按钮共享Clicked事件后如何区分是点了哪一个按钮? |
T |
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton) ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton) 在OnBnClickedButton中如何区分点了button1还是button4? |
A | 判断CWnd::GetCurrentMessage获得的消息的wParam |
Q | 如何给button改变颜色?? |
T | |
A |
绘制有纹理的背景的应用程序 (jiangsheng翻译) http://www.csdn.net/develop/read_article.asp?id=9603 |
Q | 有关属性页改名的问题!! |
T |
我用CPropertySheet创建属性页,用的CPropertyPage对象只有一个,也就是每个属性页的内容一样. 想在的问题是:这样每个属性页的标题都是一样的,是对话框的标题!怎样动态的改变这个标题,使每个属性页的标签的名称都不同?? |
A |
>怎样动态的改变这个标题,使每个属性页的标签的名称都不同?? 什么时候改?CPropertySheet创建之前/属性页激活之后? 如果是前者的话,修改CPropertySheet::m_psh 如果是后者的话,重载CPropertyPage::OnSetActive, 用GetParent()返回PropertySheet指针,然后SetWindowText In some function of your page |
Q | 请教:dlg中有一个edit编辑框,用domodal(),如果用回车的话会推出对话框,why??? |
T | 如何使它不这样啊????? |
A |
ES_WANTRETURN Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiple-line edit control in a dialog box. Without this style, pressing the ENTER key has the same effect as pressing the dialog box’s default pushbutton. This style has no effect on a single-line edit control. void CTabDialog::OnOK() |
Q | SHBrowseForFolder问题:windows2000下当用户选择桌面上的文件夹"a 在 bSvr 上"后,函数返回'C:/Documents and Settings/Administrator/ |
T |
由于'a 在 bSvr 上'是指向局域网服务器上某文件夹的快捷方式,所以向'该文件夹'(其实是快捷方式)下写文件时会出错。 但是在弹出选择文件夹对话框时,如选择‘a 在 bSvr 上’的‘NewFolder‘夹时,函数会正确返回:‘//bScr/a/NewFolder’. 如何让那个显示文件夹的对话框不显示快捷方式?或者如何在选择快捷方式后我的程序可以知道? 一下是源代码: Private Type BROWSEINFO Const BIF_RETURNONLYFSDIRS = &H1 Private Declare Function SHGetPathFromIDList _ Public Function BrowseFolder(vCaption As String, Optional vOwnerHwnd As Long = 0) As String If vOwnerHwnd <> 0 Then bi.hOwner = vOwnerHwnd |
A |
http://www.csdn.net/develop/read_article.asp?id=22243 打开文件或者目录 void CPicViewView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) |
Q | 使用图标的问题,高手请进。 |
T |
我用SHGetFileInfo得到文件图标,但在程序关闭以后,所有用到文件小图标的地方都什么也不显示了,包括资源管理器等,请各位大侠指点。以下是程序。 hImageList=(HIMAGELIST)SHGetFileInfo("C://",0,&shFi,sizeof(shFi),SHGFI_SYSICONINDEX|SHGFI_SMALLICON); if(!hImageList) return ; .m_hImageList=hImageList; 程序关闭时 if(m_ImageList.m_hImageList) |
A |
//set the large and small icon image lists himlSmall = (HIMAGELIST)SHGetFileInfo( TEXT("C://"), 0, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON); himlLarge = (HIMAGELIST)SHGetFileInfo( TEXT("C://"), |
Q | 为什么会出问题?编译是没有错误!!! |
T |
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar/n"); return -1; // fail to create } if (!m_WzdDialogBar.Create(this,IDD_WZD_DIALOG,CBRS_TOP, class CWzdDialogBar : public CDialogBar // Dialog Data // Overrides // Implementation // Generated message map functions //{{AFX_INSERT_LOCATION}} #endif // !defined(AFX_WZDDIALOGBAR_H__96035782_9BCD_11D5_AC0B_5254AB11DB8B__INCLUDED_) |
A |
为什么要这么干??如果要用DDX的话,参见 HOWTO: How to Initialize Child Controls in a Derived CDialogBar ID: Q185672 -------------------------------------------------------------------------------- The Microsoft Foundation Classes (MFC), used with: -------------------------------------------------------------------------------- SUMMARY However, in the case of a more complex CDialogBar, which might have a drop- down combo box, a treeview, or ActiveX control, it might be useful to derive from CDialogBar to provide initialization for the child controls. Because ClassWizard does not support deriving a class from CDialogBar, this article shows the steps necessary to create a class from CDialog and then "convert" the class to CDialogBar. MORE INFORMATION Change the base class from CDialog to CDialogBar in the class declaration. Don't forget to also change the base class in BEGIN_MESSAGE_MAP in the .cpp file. Change the constructor in both the .h and the .cpp files. Also make the change to the DoDataExchange(). Below are three items to change. Change the following from CMyDlgBar (CWnd* pParent = NULL); // standard constructor CMyDlgBar:: CMyDlgBar (CWnd* pParent /*=NULL*/) void CMyDlgBar::DoDataExchange(CDataExchange* pDX) CMyDlgBar (); // standard constructor CMyDlgBar:: CMyDlgBar () void CMyDlgBar::DoDataExchange(CDataExchange* pDX) class CMyDlgBar : public CDialogBar // Generated message map functions afx_msg LONG OnInitDialog ( UINT, LONG ); // <-Add this line. Add "ON_MESSAGE(WM_INITDIALOG, OnInitDialog );" to the message map in the .CPP implementation file. For example: BEGIN_MESSAGE_MAP(CMyDlgBar, CDialogBar) //{{AFX_MSG_MAP(CMyDlgBar) Make the OnInitDialog() conversion as follows: Change the following: BOOL CMyDlgBar::OnInitDialog() LONG CMyDlgBar::OnInitDialog ( UINT wParam, LONG lParam) if ( !HandleInitDialog(wParam, lParam) || !UpdateData(FALSE)) Make sure the dialog box resource styles to the following: Add an instance of the derived CDialogBar to the CframeWnd-derived class (normally called CMainFrame). For example: class CMainFrame : public CFrameWnd int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) return 0; REFERENCES Q99161 HOWTO: Derive From Classes not Listed in ClassWizard Additional query words: Keywords : kbwizard kbMFC KbUIDesign kbVC500 kbVC600 kbGrpMFCATL kbMFCCtrlBar Last Reviewed: March 8, 2000 -------------------------------------------------------------------------------- |
Q | 请问大虾:如何使自己的透明程序总在最前,但不影响用户对下面的其他程序操作 |
T | 请问大虾:如何使自己的半透明程序窗口总在最前,但不影响用户对下面的其他程序操作? |
A |
处理一下WM_NCHITTEST(参见CWnd::OnNcHitTest),返回HT_TRANSPARENT
你的程序生成一个OVERLAY(看DirectDraw),这样你的程序就在最高层(高于鼠标)。 |
Q | 如何实现像98那样的文件搜索列表? |
T | 点一下列表的表头就可以以升序或者降序进行排列的功能是如何实现的? |
A |
对于虚列表,排序的工作比较简单,更改内部数据的排序方式之后刷新就可以 下面是交换列表项的处理(很旧的代码了,写的繁琐了一点) BOOL CEnhancedListCtrl::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult) { *pResult = 0; NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; // TODO: Add your control notification handler code here if(!GetSortable())return FALSE; if(m_iSortCol==pNMListView->iSubItem){//click repeatly m_bSortAsc=!m_bSortAsc; } else{ m_bSortAsc2=m_bSortAsc; m_bSortAsc=TRUE; m_iSortCol2=m_iSortCol; m_iSortCol=pNMListView->iSubItem; } Sort(m_iSortCol,m_bSortAsc,m_iSortCol2,m_bSortAsc2,TRUE); return FALSE; } BOOL CEnhancedListCtrl::Sort(int iCol,BOOL bSortAsc,int iCol2/*=-1*/,BOOL bSortAsc2/*=TRUE*/,BOOL bRedraw/*=FALSE*/) { if(!(GetStyle()&LVS_OWNERDATA)) return g_listSortByName(*this,iCol,bSortAsc,iCol2,bSortAsc2,bRedraw); else return FALSE; } BOOL g_listSortByName(CListCtrl& list,int iSortCol,BOOL bSortAsc,int iSortCol2/*=-1*/,BOOL bSortAsc2/*=TRUE*/,BOOL bRedraw/*=FALSE*/) { if(iSortCol==-1)return FALSE; if(bRedraw) list.SetRedraw(FALSE); BOOL bRet; CWaitCursor WaitCursor; DWORD dwSortOption=0; if(bSortAsc) dwSortOption|=LVSF_ASCENDING ; if(bSortAsc2) dwSortOption|=LVSF_ASCENDING2; if(iSortCol2!=-1) dwSortOption|=LVSF_SECONDARY; //save item data LPTEMPDATA ptempData; for(int i=0;i<list.GetItemCount ();i++){ ptempData=new TEMPDATA; ptempData->strPrimary =list.GetItemText (i,iSortCol); if(iSortCol2!=-1) ptempData->strSecondary =list.GetItemText (i,iSortCol2); ptempData->data =list.GetItemData (i); list.SetItemData (i,(LPARAM)ptempData ); } //set sort options bRet=list.SortItems((PFNLVCOMPARE)g_listItemCompareByName,dwSortOption); //Restore item data for(i=0;i<list.GetItemCount ();i++){ ptempData=(LPTEMPDATA)list.GetItemData (i); list.SetItemData (i,ptempData->data ); delete ptempData; } if(int iItem=list.GetNextItem(-1,LVNI_FOCUSED)!=-1) list.EnsureVisible(iItem,FALSE); if(bRedraw) list.SetRedraw(TRUE); return bRet; } //Used by Sorting of ListView; //Note:this operation will overite the data of items temporary. int CALLBACK g_listItemCompareByName(LPARAM lParam1, LPARAM lParam2, LPARAM dwSortOption) { int nRet; BOOL bSecondary=dwSortOption&LVSF_SECONDARY ; BOOL bSortAsc=dwSortOption&LVSF_ASCENDING ; BOOL bSortAsc2=dwSortOption&LVSF_ASCENDING2; CString str1=((LPTEMPDATA)lParam1)->strPrimary ; CString str2=((LPTEMPDATA)lParam2)->strPrimary ; nRet=str1.Compare (str2); if(nRet){ if(!bSortAsc)// nRet=-nRet; } else{ if(bSecondary){// primary is the same string str1=((LPTEMPDATA)lParam1)->strSecondary ; str2=((LPTEMPDATA)lParam2)->strSecondary; nRet=str1.Compare (str2); if(!bSortAsc2)// nRet=-nRet; } } return nRet; } -- 这是演示代码,不是完整的工程 //if this bit set, sort ascending, otherwise sort descending, |
Q | 关于alt+f4 |
T |
要屏蔽alt+f4 我的想法是在onkeydown里面判断vk_alt和vk_f4同时按下,然后返回失败 不知道对不对,那么怎样判断是否两个键同时按下 |
A |
HOWTO: Disable the Window Close Button in an MDI Application ID: Q201553 -------------------------------------------------------------------------------- The Microsoft Foundation Classes (MFC), included with: -------------------------------------------------------------------------------- SUMMARY MORE INFORMATION To workaround this limitation, you can simulate the functionality of a window without a close button by disabling the close button. In the WM_CREATE message handler for the MDI child frame window (CMDIChildWnd-derived class) disable the close button with the following code: CMenu *pSysMenu = GetSystemMenu(FALSE); When the child frame window is not maximized, the above code prevents the user from closing the child frame window by clicking the close button. When the child frame window is maximized, the above code makes the close button appear disabled. However, a user can still close the child frame window by clicking this window's close button. You can prevent this by trapping the SC_CLOSE command when it is sent to the child frame window and preventing further processing of this command. To do so, use the WM_SYSCOMMAND message handler for the child frame's class, as in the following example: // CChildFrame is a CMDIChildWnd-derived class. (c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Isaac L. Varon, Microsoft Corporation. Additional query words: ChildFrame MainFrame Keywords : kbMDI kbMenu kbMFC KbUIDesign kbVC600 kbGrpMFCATL Last Reviewed: March 9, 2000 |
Q | I want to replace the cursor with my cwnd object,can you help me?! |
T | |
A |
INFO: Changing the Mouse Cursor for a Window ID: Q31747 3.00 3.10 WINDOWS kbprg -------------------------------------------------------------------------------- Microsoft Windows Software Development Kit (SDK) 3.1 -------------------------------------------------------------------------------- SUMMARY The application can use the SetCursor function, which will change the mouse cursor immediately. The application can use the SetClassWord function to change the mouse cursor for all windows of a particular window class. This method affects the mouse cursor only while it resides within the client area of a window of that class. This article provides additional details regarding these two methods. MORE INFORMATION When an application calls SetCursor, the mouse cursor changes to reflect the cursor specified in the call. The cursor retains that shape until SetCursor is called again, either explicitly by the application, by the DefWindowProc function, or by another application. Because Windows is a nonpreemptive multitasking environment, no other application will gain control of the processor until the application that has the processor releases it. If the application calls one of a number of Windows functions, it can potentially lose control of the processor. For a list of Windows functions that can cause control of the processor to pass between applications, search on the following words in the Microsoft Knowledge Base: prod(winsdk) and nonpreemptive and multitasking When the DefWindowProc or DefDlgProc function processes a WM_SETCURSOR message, it calls SetCursor to change the cursor to the default cursor for the application's window. The application can prevent the cursor from changing by processing the WM_SETCURSOR message. A typical application that processes WM_SETCURSOR will have a global variable for the handle to the current cursor. When the application receives a WM_SETCURSOR message, it checks the global variable. If the variable is NULL, the application passes the WM_SETCURSOR message to DefWindowProc. Otherwise, the application calls SetCursor with the value in the global variable. To return the cursor to the window default cursor, set the global variable to NULL. When Windows sends a WM_SETCURSOR message, it places the hit-test area code into the low-order word of the lParam parameter. The application can use the hit-test area code to determine what particular portion of the window is "under" the mouse cursor. For more information on the hit-test area codes, see the documentation for the WM_NCHITTEST message in the "Microsoft Windows Software Development Kit Reference Volume 1." Additional query words: 3.00 3.10 RegisterClass Keywords : kb16bitonly kbInput kbMouse kbSDKPlatform kbWndw When the DefWindowProc or DefDlgProc function processes a WM_SETCURSOR message, it calls SetCursor to change the cursor to the default cursor for the application's window. |
Q | 怎样在弹出式菜单中使用CheckMenuItem?我用LoadMenu(),GetSubMenu(),然后在菜单项响应处理中使用CheckMenuItem,再弹出菜单一看却无变化.(问题很菜,见笑) |
T | 怎样在弹出式菜单中使用CheckMenuItem?我用LoadMenu(),GetSubMenu(),然后在菜单项响应处理中使用CheckMenuItem,再弹出菜单一看却无变化.(问题很菜,见笑) |
A |
我已经是第N次回答这种问题了…… 下次提问前搜索一下论坛先 对话框是没有空闲时间处理的。需要加一些模拟的框架的代码才行。 http://www.csdn.net/expert/Topic/295/295161.shtm |
Q | 看在我已经熬了两个晚上的份上,各位帮帮忙,我的眼睛已经熬红了--一个向MDI程序插入MENU的问题 |
T |
我做一个浏览器程序现在要向主菜单中插入[收藏]菜单,在CMainFrame的OnCreate函数中有如下代码,这是个MDI ..... CMenu *pMenu,*tMenu; //(1) tMenu=GetMenu(); //(2) pMenu=tMenu->GetSubMenu(3); //(3) ..... 当执行到第二步时,可以获得主菜单的指针(不确定是否是真正的指针).然而在执行到第三步时,系统报错.经调试发现,在第三步执行时,tMenu变成了000000,也就是NULL,始终弄不懂已经保存下来的变量怎么会变NULL.因为这个原因,程序始终不能通过这里. 在跟踪调试到系统中时,发现程序产生一个CTEMPMENU,我在SDI的ONCREATE中同样的代码可以正确地执行,但同样的代码在MDI的同样位置就是不行.不知道是什么问题 我是打算在MDI中插入[收藏]菜单. 谢谢! |
A |
1在CChildFrame的WM_INITMENUPOPUP里面把菜单改掉 2重载CDocument::GetDefaultMenu 3在文档模板创建的时候修改菜单 修改方法参见MFCIE示例 上述方法只需采用其中一种 ChildFrame是没有Menu的,在激活ChildFrame的时候会用当前CMDIChildWnd::m_hMenuShared替换主菜单。但是直接修改CMDIChildWnd::m_hMenuShared会有问题,建议重载 1更正为 MDI的CMainFrame没有视图的,ChildFrame才有。 |
Q | 请问导航图如何实现?(玩过红警的更容易解答) |
T |
我时作组态软件的,我的把组态图画布定义的很大,想通过做一个导航框来实现方便 图像管理和移动(就象红警中的缩略地图一样,即可看全貌也可通过用鼠标拖动当前显示框来看图像的其它部分),请大家给我出个主意这玩艺该如何实现,请大家踊跃讨论! |
A |
void CEMapView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) { // TODO: Add your specialized code here and/or call the base class CScrollView::OnPrepareDC(pDC, pInfo); CEMapDoc* pDoc = GetDocument(); CSize sizeDoc = pDoc->GetSize(); CPoint ptOrg; CRect rectClient; GetClientRect(&rectClient); pDC->DPtoLP(&rectClient); ptOrg.x = min(-sizeDoc.cx / 2,-rectClient.Size().cx/2); ptOrg.y = max(sizeDoc.cy / 2,-rectClient.Size().cy/2); // ptOrg is in logical coordinates pDC->SetWindowOrg(ptOrg); } void CEMapThumbnailView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) { // TODO: Add your specialized code here and/or call the base class CEMapDoc* pDoc = GetDocument(); CSize sizeDoc=pDoc->GetSize(); CRect rectClient; GetClientRect(&rectClient); pDoc->PixelToLongEngish(&rectClient); CView::OnPrepareDC(pDC, pInfo); pDC->SetMapMode(MM_ANISOTROPIC); CSize sizeView; LONGLONG x1y2,x2y1; x1y2=Int32x32To64(sizeDoc.cx,rectClient.Width()); x2y1=Int32x32To64(sizeDoc.cy,rectClient.Height()); if(x1y2>x2y1){//image is too wide,stretch y sizeView.cx=::MulDiv(sizeDoc.cy,rectClient.Width(),rectClient.Height()); sizeView.cy=sizeDoc.cy; } else{//image is too thin,stretch x sizeView.cx=sizeDoc.cx; sizeView.cy=::MulDiv(sizeDoc.cx,rectClient.Height(),rectClient.Width()); } GetClientRect(&rectClient); pDC->SetWindowExt(sizeView); pDC->SetViewportExt(rectClient.Width(),-rectClient.Height()); CPoint ptOrg; ptOrg.x = -sizeView.cx/2; ptOrg.y = sizeView.cy/2; // ptOrg is in logical coordinates pDC->SetWindowOrg(ptOrg.x,ptOrg.y); } |
Q | 调用ProcessShellCommand()时, 出现"Failed to create empty document."错误. |
T |
Win98,VC++6.0,单文档界面,InitInstance()中调用ProcessShellCommand()时, 出现"Failed to create empty document."错误.有一台机器上出现这种错误,其他大多数机器上又没有这种错误. 烦闷啊! 可能是什么原因呢? |
A |
check the return code of CYourDocument::OnNewDocument()
上次记错了,OnNew是在后面 CDocTemplate::CreateNewFrame new了一个FrameWnd,调用了CFrameWnd::LoadFrame,而CFrameWnd::LoadFrame是可能失败的。FrameWnd在处理WM_CREATE的过程中失败就可能导致这种情况。通常的原因是CFrameWnd::CreateView失败。 注册组件的时候,要注意组件的ProgID。为了安全起见,需要先撤销原有控件的注册,才能正常注册组件。 |
Q | 怎么编程去点击别的程序的按钮??? |
T |
我知道可以用SendMessage() 可是,句柄呢? ID? 怎么控制那个按钮阿? |
A |
//this program use EnumChildWindows to enumerate all the child windows of the dialog... can be changed to enumerate all the child windows of the desktop. #include <afxtempl.h> // Information about child controls in the Visual Basic class CTestVBDlg : public CDialog // Callback function for EnumChildWindows() API CString str; return TRUE; BOOL CTestVBDlg ::OnInitDialog() // Setup a callback function for EnumChildWindows() API to ::SendMessage(child, BM_CLICK, 0, 0L); // OPTIONAL!!! if (!trap_accel) |
Q | 大家都知道弹出模式对话框(CDialog), 有谁知道如何产生 弹出模式CFrameWnd(他是个CFrameWnd, 不过弹出后, 会锁定母CFrameWnd) 多多UP |
T | 大家都知道弹出模式对话框(CDialog), 有谁知道如何产生 弹出模式CFrameWnd(他是个CFrameWnd, 不过弹出后, 会锁定母CFrameWnd) |
A |
CReportErrorDlg::OnSend() { CWhatWereYouDoingDlg dlg1(this); dlg1.m_strString = m_strWhatWereYouDoing; if(dlg1.DoModal() == IDOK) { m_strWhatWereYouDoing = dlg1.m_strString; HINSTANCE hMail = NULL; hMail = ::LoadLibraryA("MAPI32.DLL"); if (hMail == NULL) { AfxMessageBox(AFX_IDP_FAILED_MAPI_LOAD); return; } ASSERT(hMail != NULL); ULONG (PASCAL *lpfnSendMail)(ULONG, ULONG, MapiMessage*, FLAGS, ULONG); // make a recipient CString s =m_strWhatWereYouDoing; message.lpszNoteText = s.GetBuffer(s.GetLength()); // prepare for modal dialog box // some extra precautions are required to use int nError =lpfnSendMail(0, (ULONG)pParentWnd->GetSafeHwnd(), // after returning from the MAPISendMail call, pParentWnd->EnableWindow(TRUE); if (nError != SUCCESS_SUCCESS && nError !=MAPI_USER_ABORT && nError !=MAPI_E_LOGIN_FAILURE) 注意这些 // some extra precautions are required to use 结束模态 pParentWnd->EnableWindow(TRUE); |
界面(1):对话框和菜单 打印和按钮等杂项相关推荐
- 字面常量_从字面上看,“打印屏幕”按钮是否可以打印屏幕(并且可以再次打印)吗?
字面常量 The computing landscape is full of vestigial bits and pieces from the history of computer devel ...
- 【转】走进windows编程的世界-----对话框、文本框、按钮
一.对话框 1 对话框的分类 2 对话框的基本使用方式 3 对话框资源 4 有模式对话框的使用 int DialogBox( HINSTANCE hInstance, LPCTSTR lpTemp ...
- 猎豹MFC--CMenu菜单 设置主菜单 给主对话框设置菜单 设置快捷菜单
设置主菜单(不是快捷菜单): 给主对话框设置菜单: 效果如下: 修改菜单的ID使之便于记忆: 给菜单添加消息处理: 添加处理代码: 设置快捷菜单: 打开对话框,属性添加消息 上文菜单 快捷菜单消息 ...
- vb6 打印选项对话框_图纸打印次数太多,不知道哪次才是最新的?用打印戳记区分效果好...
原创:就说我在开发区 使用AutoCAD从事设计工作的朋友们不知道有没遇到过这种情况: 图纸在反复修改打印的过程中,由于图纸内容高度相似,往往搞不清究竟哪个才是最新版本的图纸了. 这种情况下,细致入微 ...
- Material Design【Android-Toolbar,滑动菜单,悬浮按钮,卡片布局,下拉刷新和可折叠式标题栏及案例】
文章目录 Material Design--界面设计 1.Toolbar,标题栏 2.滑动菜单 3.悬浮按钮和可交互提示 4.卡片布局 5.下拉刷新 6.可折叠式标题栏 Material Design ...
- 孙鑫对话框二中为什么要对按钮控件新建一个类(小结,5.2给出了结论)
为类添加消息处理函数与成员变量,因为要对控件添加WM_MOUSEMOVE消息处理函数,而控件变量本身 不能加消息处理函数,只有类才能添加,所以要创建CNewButton类,然后使按钮控件属于这个类,当 ...
- android选项菜单源代码,Android应用程序----UI界面控件(菜单menu)
菜单是应用程序中非常重要的组成部分,能够在不占用界面空间的前提下,为应用程序提供了统一的功能和设置界面,并为程序开发人员提供了易于使用的编程接口 Android系统支持三种菜单 选项菜单(Option ...
- 实现带下拉菜单的工具栏按钮
在工具栏中使用真彩色图标 实现带下拉菜单的工具栏按钮 20050916
- 解决微信“聊天界面中的新消息通知”设置按钮不见了问题
原因 解决微信"聊天界面中的新消息通知"设置按钮不见了问题 解决方法 开启"接收新消息通知"后,"聊天界面中的新消息通知"设置按钮就会出现
最新文章
- 程序还没写完只能当然计算器用,先发过来用着后面的慢慢写
- 人工智能写散文之错位时空
- LSTM入门学习——结合《LSTM模型》文章看
- svn(subversion)代码版本管理在linux下的一些常见使用命令
- Codeforces 482E ELCA (LCT)
- Java8-Guava实战示例
- 前端学习(2917):上午回顾
- 打击犯罪(信息学奥赛一本通-T1386)
- 记录——《C Primer Plus (第五版)》第十一章编程练习第一题
- ansible之安装与简单使用
- 《『若水新闻』客户端开发教程》——09.代码编写(1)
- Python入门--else语句
- 1005	地球人口承载力估计
- 侧信道攻击之模板攻击
- 十分钟掌握Google Guice(上)
- 基于智能手机传感器数据的人类行为识别
- 烧一根不均匀的绳,从头烧到尾总共需要1个小时。现在有若干条材质相同的绳子,问如何用烧绳的方法来计时一 个小时十五分钟呢?(微软面试题)
- 计算机登录界面没有用户显示不出来,电脑开机时提示用户界面失败:无法加载登录用户界面的解决方法...
- 我涉及的数据可视化的实现技术和工具
- 黄梯云主编管理信息系统课后答案1-6