-
-
[求助]为什么工具栏死不出字
-
发表于: 2014-4-4 20:27 2785
-
我是在vc6 xpsp3写的 用win32窗口程序 我已经用汇编语言翻译过来了,汇编是可以的。TNND不知道哪里问题。附上源码,再附上xp sp2 sdk 我只保留里面的include lib文件夹 其它都是例子,删了。记得在Project Setting---->Link里面的加上comctl32.lib才可以。本人QQ1684751684,换QQ啦。http://pan.baidu.com/share/home?uk=369404009
#include <windows.h>
#include <commctrl.h>
char szWindowClass[]="这个是主要窗口";
char szPathSpec[]="D:\\翻译";
MSG msg;
WNDCLASSEX wcex;
TBBUTTON j1[]={
{2,0x6523,TBSTATE_ENABLED,0,0,0,(INT_PTR)"hjuhg"},
{9,0x562,TBSTATE_ENABLED,BTNS_SHOWTEXT,0,0,(INT_PTR)"好几个"},
{13,0x563,TBSTATE_ENABLED,0,0,0,(INT_PTR)"护士打假皇帝"},
{1,0x564,TBSTATE_ENABLED,0,0,0,0}
};
TBADDBITMAP tbab={HINST_COMMCTRL,IDB_STD_LARGE_COLOR};
INITCOMMONCONTROLSEX iccs={sizeof(INITCOMMONCONTROLSEX), ICC_WIN95_CLASSES };
HWND hWnd;
HWND hToolbar;
HINSTANCE hIns;
LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
hIns = hInstance;
InitCommonControlsEx(&iccs);
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(0,IDI_HAND);
wcex.hCursor = LoadCursor(0,IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wcex.lpszMenuName = 0;
wcex.lpszClassName = szWindowClass;
RegisterClassEx(&wcex);
hWnd = CreateWindowEx(0,szWindowClass,szPathSpec,WS_OVERLAPPEDWINDOW,200,200,400,300,NULL,0,hInstance,NULL);
ShowWindow(hWnd,SW_SHOWNORMAL);
UpdateWindow(hWnd);
while (GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam) // second message parameter
{
if (uMsg == WM_CREATE)
{ //工具栏
hToolbar = CreateWindowEx(0,"ToolbarWindow32",0,CCS_NODIVIDER | WS_CHILD | WS_VISIBLE,0,0,0,0,hwnd,(HMENU)36,hIns,0);
SendMessage(hToolbar,TB_ADDBITMAP,0,(LPARAM)&tbab);
SendMessage(hToolbar,TB_BUTTONSTRUCTSIZE,sizeof(TBBUTTON),0);
SendMessage(hToolbar,TB_ADDBUTTONS,4,(LPARAM)&j1[0]);
SendMessage(hToolbar,TB_AUTOSIZE,0,0); //工具栏必须发这个才能显示正常
}
else if (uMsg == WM_CLOSE)
{
DestroyWindow(hwnd);
PostQuitMessage(0);
}
else
return DefWindowProc(hwnd,uMsg,wParam,lParam);
return 0;
}
#include <windows.h>
#include <commctrl.h>
char szWindowClass[]="这个是主要窗口";
char szPathSpec[]="D:\\翻译";
MSG msg;
WNDCLASSEX wcex;
TBBUTTON j1[]={
{2,0x6523,TBSTATE_ENABLED,0,0,0,(INT_PTR)"hjuhg"},
{9,0x562,TBSTATE_ENABLED,BTNS_SHOWTEXT,0,0,(INT_PTR)"好几个"},
{13,0x563,TBSTATE_ENABLED,0,0,0,(INT_PTR)"护士打假皇帝"},
{1,0x564,TBSTATE_ENABLED,0,0,0,0}
};
TBADDBITMAP tbab={HINST_COMMCTRL,IDB_STD_LARGE_COLOR};
INITCOMMONCONTROLSEX iccs={sizeof(INITCOMMONCONTROLSEX), ICC_WIN95_CLASSES };
HWND hWnd;
HWND hToolbar;
HINSTANCE hIns;
LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
hIns = hInstance;
InitCommonControlsEx(&iccs);
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(0,IDI_HAND);
wcex.hCursor = LoadCursor(0,IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wcex.lpszMenuName = 0;
wcex.lpszClassName = szWindowClass;
RegisterClassEx(&wcex);
hWnd = CreateWindowEx(0,szWindowClass,szPathSpec,WS_OVERLAPPEDWINDOW,200,200,400,300,NULL,0,hInstance,NULL);
ShowWindow(hWnd,SW_SHOWNORMAL);
UpdateWindow(hWnd);
while (GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam) // second message parameter
{
if (uMsg == WM_CREATE)
{ //工具栏
hToolbar = CreateWindowEx(0,"ToolbarWindow32",0,CCS_NODIVIDER | WS_CHILD | WS_VISIBLE,0,0,0,0,hwnd,(HMENU)36,hIns,0);
SendMessage(hToolbar,TB_ADDBITMAP,0,(LPARAM)&tbab);
SendMessage(hToolbar,TB_BUTTONSTRUCTSIZE,sizeof(TBBUTTON),0);
SendMessage(hToolbar,TB_ADDBUTTONS,4,(LPARAM)&j1[0]);
SendMessage(hToolbar,TB_AUTOSIZE,0,0); //工具栏必须发这个才能显示正常
}
else if (uMsg == WM_CLOSE)
{
DestroyWindow(hwnd);
PostQuitMessage(0);
}
else
return DefWindowProc(hwnd,uMsg,wParam,lParam);
return 0;
}
赞赏
他的文章
- [求助]为什么工具栏死不出字 2786
- [分享][原创]最简单的MFC程序 6495
- [分享]开源、中文注释的反汇编引擎 18171
- [原创]PE格式解析 18354
- [原创]刚刚做了一个反汇编工具 4312
看原图
赞赏
雪币:
留言: