在对话框中建立一个trackbar
我添加了头文件和导入了lib库,可是还是出现错误,不知道怎么解决。我给出部分代码#include <commctrl.h>
#pragma comment(lib,"comctl32.lib") int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
MSG msg;
HWND hDlg;
hIns=hInstance;
hDlg=CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DLG),NULL,
(DLGPROC)DialogFunc);
HWND hwndTrack;
INITCOMMONCONTROLSEX cc;
cc.dwICC=ICC_BAR_CLASSES;
cc.dwSize=sizeof(INITCOMMONCONTROLSEX);
InitCommonControls(&cc); // loads common control's DLL hwndTrack = CreateWindowEx(
0, // no extended styles
TRACKBAR_CLASS, // class name
"Trackbar Control", // title (caption)
WS_CHILD | WS_VISIBLE |
TBS_AUTOTICKS | TBS_ENABLESELRANGE, // style
10, 300, // position
200, 22, // size
hDlg, // parent window
(HMENU)ID_TRACKBAR, // control identifier
hIns, // instance
NULL // no WM_CREATE parameter
);
ShowWindow(hDlg,SW_SHOWNORMAL);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}错误提示是
--------------------配置: MinGW3.4.5 - GUI Debug, 编译器类型: MinGW--------------------检查文件依赖性...
正在编译 C:\Documents and Settings\Administrator\My Documents\C-Free\Projects\mp_05\mp_01.cpp...
[Error] C:\Documents and Settings\Administrator\My Documents\C-Free\Projects\mp_05\mp_01.cpp:75: error: `INITCOMMONCONTROLSEX' was not declared in this scope
[Error] C:\Documents and Settings\Administrator\My Documents\C-Free\Projects\mp_05\mp_01.cpp:75: error: expected `;' before "cc"
[Error] C:\Documents and Settings\Administrator\My Documents\C-Free\Projects\mp_05\mp_01.cpp:76: error: `cc' was not declared in this scope构建中止 mp_01: 3 个错误
我添加了头文件和导入了lib库,可是还是出现错误,不知道怎么解决。我给出部分代码#include <commctrl.h>
#pragma comment(lib,"comctl32.lib") int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
MSG msg;
HWND hDlg;
hIns=hInstance;
hDlg=CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DLG),NULL,
(DLGPROC)DialogFunc);
HWND hwndTrack;
INITCOMMONCONTROLSEX cc;
cc.dwICC=ICC_BAR_CLASSES;
cc.dwSize=sizeof(INITCOMMONCONTROLSEX);
InitCommonControls(&cc); // loads common control's DLL hwndTrack = CreateWindowEx(
0, // no extended styles
TRACKBAR_CLASS, // class name
"Trackbar Control", // title (caption)
WS_CHILD | WS_VISIBLE |
TBS_AUTOTICKS | TBS_ENABLESELRANGE, // style
10, 300, // position
200, 22, // size
hDlg, // parent window
(HMENU)ID_TRACKBAR, // control identifier
hIns, // instance
NULL // no WM_CREATE parameter
);
ShowWindow(hDlg,SW_SHOWNORMAL);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}错误提示是
--------------------配置: MinGW3.4.5 - GUI Debug, 编译器类型: MinGW--------------------检查文件依赖性...
正在编译 C:\Documents and Settings\Administrator\My Documents\C-Free\Projects\mp_05\mp_01.cpp...
[Error] C:\Documents and Settings\Administrator\My Documents\C-Free\Projects\mp_05\mp_01.cpp:75: error: `INITCOMMONCONTROLSEX' was not declared in this scope
[Error] C:\Documents and Settings\Administrator\My Documents\C-Free\Projects\mp_05\mp_01.cpp:75: error: expected `;' before "cc"
[Error] C:\Documents and Settings\Administrator\My Documents\C-Free\Projects\mp_05\mp_01.cpp:76: error: `cc' was not declared in this scope构建中止 mp_01: 3 个错误
解决方案 »
- 请问VC使用TeeChart的问题(如何更改Point类型曲线的点样式)?
- 如何使用程序设置VISTA/WIN7的开机引导项?
- 如何在一个空的DLL工程中创建窗体??
- 如何在网上更好的宣传自己的软件!来者有分!!
- help文档调用
- 一个编程问题,关于文件操作的
- 关于建立“网络游戏开发结构模型”的提议
- !!!!!!!!!!!!恳请高手帮忙解决屏幕捕捉方面的问题!!!! (钩子函数相关)
- 关于C++模拟键盘录入的古怪问题。
- MFC中CWnd::Create()中UINT nID参数的问题?
- YFOPCSDK.dll谁用过? 是否免费??(一个开发OPC客户端的动态库)
- MFC 袖珍服务器 程序,在嵌入其它程序中,如何得到屏幕坐标?
typedef struct tagINITCOMMONCONTROLSEX {
DWORD dwSize;
DWORD dwICC;
} INITCOMMONCONTROLSEX, *LPINITCOMMONCONTROLSEX;
#include <commctrl.h>
#include "resource.h"
// #pragma comment(lib,"comctl32.lib")
int WINAPI DialogFunc(HWND wnd, UINT uMsg, WPARAM wp, LPARAM lp);
#define ID_TRACKBAR 1
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
MSG msg;
HWND hDlg;
HINSTANCE hIns=hInstance;
hDlg=CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DLG),NULL,
(DLGPROC)DialogFunc);
HWND hwndTrack;
INITCOMMONCONTROLSEX cc;
cc.dwICC=ICC_BAR_CLASSES;
cc.dwSize=sizeof(INITCOMMONCONTROLSEX);
InitCommonControls(); // loads common control's DLL
hwndTrack = CreateWindowEx(
0, // no extended styles
TRACKBAR_CLASS, // class name
"Trackbar Control", // title (caption)
WS_CHILD | WS_VISIBLE |
TBS_AUTOTICKS | TBS_ENABLESELRANGE, // style
10, 300, // position
200, 22, // size
hDlg, // parent window
(HMENU)ID_TRACKBAR, // control identifier
hIns, // instance
NULL // no WM_CREATE parameter
);
ShowWindow(hDlg,SW_SHOWNORMAL);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}int WINAPI DialogFunc(HWND wnd, UINT uMsg, WPARAM wp, LPARAM lp)
{
return true;
}