文号
t22305
阅读
6098
回复
11
收藏
6
有關c++ CreateWindow................."
2010/01/25
IP:香港
#include "stdafx.h"
#include <windows.h>
#include <windowsx.h>
#include <iostream>
//#define WIN_INTERNAL
using namespace std;
int main(void)
{
    HWND hWnd;
    CreateWindow(
             WS_VISIBLE|WS_POPUP,  // 窗體模樣
             "szClass",   // 註冊的類別名
             "MyWindow",  // 窗體名稱
             WS_VISIBLE|WS_POPUP,// 窗體模樣
             0,                 // 水平 X 位置
             0,                 // 垂直 Y 位置
             320,            // 窗體寬度
             320,           // 窗體高度
             NULL,       // 父窗體
             NULL,           // 指向功能表的句柄
             NULL,      // 實例句柄
             NULL         // CREATESTRUCT 結構指針
             );
    ShowWindow();
    UpdateWindow();
}
出現以下錯誤= ="
1>------ 已開始建置: 專案: 創建windows, 組態: Debug Win32 ------
1>正在編譯...
1>創建windows.cpp
1>c:\documents and settings\administrator\my documents\visual studio 2008\projects\創建windows\創建windows\創建windows.cpp(26) : warning C4002: 巨集 'CreateWindowW' 的實質參數太多
1>c:\documents and settings\administrator\my documents\visual studio 2008\projects\創建windows\創建windows\創建windows.cpp(26) : error C2664: 'CreateWindowExW' : 無法將參數 2 從 'unsigned long' 轉換成 'LPCWSTR'
1>        從整數類資料型別轉換為指標型別必須有 reinterpret_cast、C-Style 轉換或函式樣式轉換
1>c:\documents and settings\administrator\my documents\visual studio 2008\projects\創建windows\創建windows\創建windows.cpp(27) : error C2660: 'ShowWindow' : 函式不使用 0 引數
1>c:\documents and settings\administrator\my documents\visual studio 2008\projects\創建windows\創建windows\創建windows.cpp(28) : error C2660: 'UpdateWindow' : 函式不使用 0 引數
1>已將建置記錄儲存於 "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\創建windows\創建windows\Debug\BuildLog.htm"
1>創建windows - 3 個錯誤,1 個警告
========== 建置: 0 成功、1 失敗、0 最新、0 略過 ==========

在下用MSVC++2008EXPREE的
可以的話能否說明一下結構(不知道有否理解錯誤)= =
t-600作者
17年0个月前IP:未同步
180955
4楼
另外這個問題其中一個核心是
reinterpret_cast、C-Style 該用了
WS_VISIBLE|WS_POPUP來表達的
這是show一個自己定義的window  有其他可能方案嗎?= ="
引用
评论
t-600作者
17年0个月前IP:未同步
180971
6楼
像這樣??

HWND hWnd;
    CreateWindow(
              LPCTSTR WS_VISIBLE|WS_POPUP,  // 窗體模樣
              LPCTSTR "szClass",  // 註冊的類別名
              LPCTSTR "MyWindow",  // 窗體名稱
              LPCTSTR WS_VISIBLE|WS_POPUP,// 窗體模樣
              LPCTSTR 0,                // 水平 X 位置
              LPCTSTR 0,                // 垂直 Y 位置
              LPCTSTR 320,            // 窗體寬度
              LPCTSTR 320,          // 窗體高度
              LPCTSTR NULL,      // 父窗體
              LPCTSTR NULL,          // 指向功能表的句柄
              LPCTSTR NULL,      // 實例句柄
              LPCTSTR NULL        // CREATESTRUCT 結構指針
             );
    ShowWindow(hWnd,nCmdShow);
    UpdateWindow(hWind);
引用
评论
t-600作者
17年0个月前IP:未同步
180976
8楼
#include "stdafx.h"
#include "stdafx.h"
#include <windows.h>
#include <windowsx.h>
#include <iostream>
//#define WIN_INTERNAL
using namespace std;
int main(void)
{
    HWND hWnd;
    CreateWindow(
             WS_VISIBLE|WS_POPUP,  // 窗體模樣
             "szClass",  // 註冊的類別名
             "MyWindow",  // 窗體名稱
             WS_VISIBLE|WS_POPUP,// 窗體模樣
             0,                // 水平 X 位置
             0,                // 垂直 Y 位置
             320,            // 窗體寬度
             320,          // 窗體高度
             NULL,      // 父窗體
             NULL,          // 指向功能表的句柄
             //NULL,      // 實例句柄
             NULL        // CREATESTRUCT 結構指針
             );
    ShowWindow(hWnd,SW_SHOW);
    UpdateWindow(hWnd);
}
nCmdShow
要找內部定義 = =
找到了SW_SHOW這個= ="
引用
评论
笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的