⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_64114.htm

📁 vc
💻 HTM
字号:
<p>
序号:64114 发表者:晴天听雨 发表日期:2003-12-08 22:03:59
<br>主题:求助:创建窗口,急!!!
<br>内容:我创建了一个数据文件,想在单击菜单后创建一个窗口,显示出数据<BR>下面是我函数的一部分:<BR>void CSobelKirschView::OnResult() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add your command handler code here<BR>&nbsp;&nbsp;&nbsp;&nbsp;HANDLE&nbsp;&nbsp;hFile;<BR>&nbsp;&nbsp;&nbsp;&nbsp;DWORD&nbsp;&nbsp; nBytesRead,dwSize,dwFilePointer,i;<BR>&nbsp;&nbsp;&nbsp;&nbsp;TCHAR&nbsp;&nbsp; gachBuffer[400] ;<BR>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;&nbsp;&nbsp;&nbsp; szFileName[128]=&#34;d:\\结果\\testrst.dat\0&#34;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;HWND&nbsp;&nbsp;&nbsp;&nbsp;hWnd;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;HANDLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hCurInst;<BR>&nbsp;&nbsp; HWND&nbsp;&nbsp;hLst1=CreateWindow(&#34;LISTBOX&#34;, &#34;序号&nbsp;&nbsp;&nbsp;&nbsp; 均值&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;四邻接绝对不均匀度&nbsp;&nbsp;&nbsp;&nbsp;直方图绝对不均匀度&nbsp;&nbsp;年 .月.日 时:分:秒&#34;,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WS_CHILD|WS_VISIBLE|LBS_NOTIFY|WS_VSCROLL<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |WS_BORDER|WS_THICKFRAME|WS_CAPTION,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200,60,300,400,NULL,NULL,hCurInst,NULL);//*****<BR>在加*的这一句编译是总提示:<BR>D:\VC程序—Chp\VC图象处理程序\新SobelKirsch\SobelKirschView.cpp(1268) : error C2664: 'CreateWindowExA' : cannot convert parameter 11 from 'void *' to 'struct HINSTANCE__ *'<BR>我不明白这是什么意思<BR>对于这个创建窗口的函数,它的参数怎么设定呢?请大家帮帮我,很急!!!!!<BR>谢谢!!!!!<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:dstwwx 回复日期:2003-12-08 22:25:04
<br>内容:改成:<BR>HWND&nbsp;&nbsp;hLst1=CreateWindow(&#34;LISTBOX&#34;, &#34;序号&nbsp;&nbsp;&nbsp;&nbsp; 均值&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;四邻接绝对不均匀度&nbsp;&nbsp;&nbsp;&nbsp;直方图绝对不均匀度&nbsp;&nbsp;年 .月.日 时:分:秒&#34;,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WS_CHILD|WS_VISIBLE|LBS_NOTIFY|WS_VSCROLL<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |WS_BORDER|WS_THICKFRAME|WS_CAPTION,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200,60,300,400,NULL,NULL,(HINSTANCE)hCurInst,NULL);//*****<BR><BR><BR>//注意,你的很多参数都是没有初始化的,可能会出错<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:platin 回复日期:2003-12-08 22:59:09
<br>内容:一般控件有两种创建方式:<BR>1。在资源文件中制定。<BR>2。用CreateWindow或者CreateWindowEx。<BR><BR>CreateWindows原型是:<BR><BR><BR>HWND CreateWindow(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LPCTSTR lpClassName,&nbsp;&nbsp;&nbsp;&nbsp; // 窗口类信息<BR>&nbsp;&nbsp;&nbsp;&nbsp;LPCTSTR lpWindowName,&nbsp;&nbsp;&nbsp;&nbsp;// 标题<BR>&nbsp;&nbsp;&nbsp;&nbsp;DWORD dwStyle,&nbsp;&nbsp; // 风格<BR>&nbsp;&nbsp;&nbsp;&nbsp;int x,int y,&nbsp;&nbsp;&nbsp;&nbsp;// 左上角坐标<BR>&nbsp;&nbsp;&nbsp;&nbsp;int nWidth,int nHeight,&nbsp;&nbsp;&nbsp;&nbsp;// 宽度和高度<BR>&nbsp;&nbsp;&nbsp;&nbsp;HWND hWndParent,&nbsp;&nbsp;&nbsp;&nbsp;// 父窗口句柄<BR>&nbsp;&nbsp;&nbsp;&nbsp;HMENU hMenu,&nbsp;&nbsp;&nbsp;&nbsp;// ID标识值或者菜单表示值<BR>&nbsp;&nbsp;&nbsp;&nbsp;HINSTANCE hInstance,&nbsp;&nbsp; // 当前实例句柄<BR>&nbsp;&nbsp;&nbsp;&nbsp;LPVOID lpParam&nbsp;&nbsp; // 指向一个 CREATESTRUCT 结构,一般为null<BR>);<BR><BR>以下是msdn的说明,更详细的你自己查msdn吧。<BR><BR>lpClassName<BR>[in] Pointer to a null-terminated string or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero. If lpClassName is a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, provided that the module that registers the class is also the module that creates the window. The class name can also be any of the predefined system class names. For a list of system class names, see the Remarks section. <BR>lpWindowName<BR>[in] Pointer to a null-terminated string that specifies the window name. If the window style specifies a title bar, the window title pointed to by lpWindowName is displayed in the title bar. When using CreateWindow to create controls, such as buttons, check boxes, and static controls, use lpWindowName to specify the text of the control. When creating a static control with the SS_ICON style, use lpWindowName to specify the icon name or identifier. To specify an identifier, use the syntax &#34;#num&#34;. <BR>dwStyle<BR>[in] Specifies the style of the window being created. This parameter can be a combination of window styles, plus the control styles indicated in the Remarks section. <BR>x<BR>[in] Specifies the initial horizontal position of the window. For an overlapped or pop-up window, the x parameter is the initial x-coordinate of the window's upper-left corner, in screen coordinates. For a child window, x is the x-coordinate of the upper-left corner of the window relative to the upper-left corner of the parent window's client area. If this parameter is set to CW_USEDEFAULT, the system selects the default position for the window's upper-left corner and ignores the y parameter. CW_USEDEFAULT is valid only for overlapped windows; if it is specified for a pop-up or child window, the x and y parameters are set to zero. <BR>y<BR>[in] Specifies the initial vertical position of the window. For an overlapped or pop-up window, the y parameter is the initial y-coordinate of the window's upper-left corner, in screen coordinates. For a child window, y is the initial y-coordinate of the upper-left corner of the child window relative to the upper-left corner of the parent window's client area. For a list box, y is the initial y-coordinate of the upper-left corner of the list box's client area relative to the upper-left corner of the parent window's client area. If an overlapped window is created with the WS_VISIBLE style bit set and the x parameter is set to CW_USEDEFAULT, the system ignores the y parameter. <BR>nWidth<BR>[in] Specifies the width, in device units, of the window. For overlapped windows, nWidth is either the window's width, in screen coordinates, or CW_USEDEFAULT. If nWidth is CW_USEDEFAULT, the system selects a default width and height for the window; the default width extends from the initial x-coordinate to the right edge of the screen, and the default height extends from the initial y-coordinate to the top of the icon area. CW_USEDEFAULT is valid only for overlapped windows; if CW_USEDEFAULT is specified for a pop-up or child window, nWidth and nHeight are set to zero. <BR>nHeight<BR>[in] Specifies the height, in device units, of the window. For overlapped windows, nHeight is the window's height, in screen coordinates. If nWidth is set to CW_USEDEFAULT, the system ignores nHeight. <BR>hWndParent<BR>[in] Handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. This parameter is optional for pop-up windows. <BR>Windows 2000/XP: To create a message-only window, supply HWND_MESSAGE or a handle to an existing message-only window. <BR><BR>hMenu<BR>[in] Handle to a menu, or specifies a child-window identifier depending on the window style. For an overlapped or pop-up window, hMenu identifies the menu to be used with the window; it can be NULL if the class menu is to be used. For a child window, hMenu specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events. The application determines the child-window identifier; it must be unique for all child windows with the same parent window. <BR>hInstance<BR>[in] Windows 95/98/Me: Handle to the instance of the module to be associated with the window. <BR>Windows NT/2000/XP: This value is ignored.<BR><BR>lpParam<BR>[in] Pointer to a value to be passed to the window through the CREATESTRUCT structure passed in the lpParam parameter the WM_CREATE message. If an application calls CreateWindow to create a multiple-document interface (MDI) client window, lpParam must point to a CLIENTCREATESTRUCT structure. <BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:晴天听雨 回复日期:2003-12-09 09:17:00
<br>内容:谢谢二位,你们的回答我很感谢,我按第一位朋友的改了程序<BR>现在可以了<BR>可是我不明白这个参数为甚末这样设置,它到底是什么,就想你所说的,<BR>我的很多参数都没有初始化,可是怎么初始化呢?在OnResult()函数中怎么得到这个实例句柄呢?这个LISTBOX是不是一个类呢?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -