关于COMCTL32.DLL(高手请进)

whowho 2003-07-09 05:06:16
一部分控件是在COMCTL32.dll中,其中包括了每个控件的窗口过程及注册窗口类的代码,他们在DLL加载时被调用。
问问:能写个代码出来看看吗(WINDOWS SDK),模拟一下COMCTL32.dll的运行过程
...全文
706 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Zark 2003-07-11
  • 打赏
  • 举报
回复
写个资源编辑器是个工程量很大的活,如果你是一个人,又没有资金支持,我劝你还是算了.
whowho 2003-07-11
  • 打赏
  • 举报
回复
(资源编辑器)
Zark 2003-07-11
  • 打赏
  • 举报
回复
你是想模似写个resource editor(资源编辑器),还是想写个Custom Control(用户自定义控件)?
whowho 2003-07-10
  • 打赏
  • 举报
回复
我是想模拟controls面版上控件(如BUTTON)在FROM上的创建过程,但移动到FROM上的这个控件是包含在一个DLL文件中的
无敌魔仙 2003-07-10
  • 打赏
  • 举报
回复
HELLO.C

--------------------------------------------------------------------------------

/*++

Copyright (c) 1998 Microsoft Corporation
All rights reserved.

Module Name:Hello

--*/

/**************************************************************
This is a simple Hello program with an application-defined function,
CreateAToolBar, that creates a toolbar. CreateAToolBar uses
CreateWindowEx to create a toolbar with three buttons. The buttons
have text labels. The label text is loaded from hello.rc and the
identifiers for the buttons are defined in hello.h.
**************************************************************/

#include
#include
#include "hello.h"


long PASCAL WndProc (HWND, UINT, WPARAM, LPARAM);
HWND CreateAToolBar(HWND);

HINSTANCE hInst;
int NUM_BUTTONS = 3;

int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow)
{
static char szAppName[ ] = "HelloWin";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;

if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;

RegisterClass (&wndclass);
}

hwnd = CreateWindow(szAppName,
"The Hello Program",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);

hInst = hInstance;
ShowWindow (hwnd, nCmdShow);
UpdateWindow (hwnd);

while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}

long APIENTRY WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;

switch (message)
{
case WM_CREATE:
CreateAToolBar(hwnd);
return 0;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps);
GetClientRect (hwnd, &rect);
SetBkMode(hdc, TRANSPARENT);
DrawText (hdc, "Hello Windows!", -1, &rect,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
SetTextColor(hdc, RGB(255, 0, 0));
TextOut(hdc, rect.right/2, 200, "Hello World", 11);
EndPaint (hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage (0);
return 0;
}

return DefWindowProc (hwnd, message, wParam, lParam);
}

HWND CreateAToolBar(HWND hwndParent)
{
HWND hwndTB;
TBBUTTON tbb[3];
char szBuf[16];
int iCut, iCopy, iPaste;
int MAX_LEN = 10;
INITCOMMONCONTROLSEX icex;

// Ensure that the common control DLL is loaded.
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
//Create a toolbar that the user can customize and that has a
// ToolTip associated with it.
hwndTB = CreateWindowEx(0, TOOLBARCLASSNAME, (LPSTR) NULL,
WS_CHILD | TBSTYLE_TOOLTIPS | CCS_ADJUSTABLE,
0, 0, 0, 0, hwndParent, (HMENU) ID_TOOLBAR, hInst, NULL);

// Send the TB_BUTTONSTRUCTSIZE message, which is required for
// backward compatibility.
SendMessage(hwndTB, TB_BUTTONSTRUCTSIZE,
(WPARAM) sizeof(TBBUTTON), 0);


// Add the button strings to the toolbar.
LoadString(hInst, IDS_CUT, (LPSTR) &szBuf, MAX_LEN);
iCut = SendMessage(hwndTB, TB_ADDSTRING, 0, (LPARAM) (LPSTR) &szBuf);

LoadString(hInst, IDS_COPY, (LPSTR) &szBuf, MAX_LEN);
iCopy = SendMessage(hwndTB, TB_ADDSTRING, (WPARAM) 0,
(LPARAM) (LPSTR) szBuf);

LoadString(hInst, IDS_PASTE, (LPSTR) &szBuf, MAX_LEN);
iPaste = SendMessage(hwndTB, TB_ADDSTRING, (WPARAM) 0,
(LPARAM) (LPSTR) szBuf);


// Fill the TBBUTTON array with button information, and add the
// buttons to the toolbar.
tbb[0].iBitmap = -1;
tbb[0].idCommand = IDS_CUT;
tbb[0].fsState = TBSTATE_ENABLED;
tbb[0].fsStyle = TBSTYLE_BUTTON;
tbb[0].dwData = 0;
tbb[0].iString = iCut;

tbb[1].iBitmap = -1;
tbb[1].idCommand = IDS_COPY;
tbb[1].fsState = TBSTATE_ENABLED;
tbb[1].fsStyle = TBSTYLE_BUTTON;
tbb[1].dwData = 0;
tbb[1].iString = iCopy;

tbb[2].iBitmap = -1;
tbb[2].idCommand = IDS_PASTE;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_AUTOSIZE;
tbb[2].dwData = 0;
tbb[2].iString = iPaste; //(int) pszBuf2;

SendMessage(hwndTB, TB_ADDBUTTONS, (WPARAM) NUM_BUTTONS,
(LPARAM) (LPTBBUTTON) &tbb);

SendMessage(hwndTB, TB_AUTOSIZE, 0, 0);
ShowWindow(hwndTB, SW_SHOWNORMAL);

return hwndTB;
}

/*


*/



--------------------------------------------------------------------------------

© 2002 Microsoft Corporation. All rights reserved.
Zark 2003-07-10
  • 打赏
  • 举报
回复
不知是什么意思?

你既然知道了控件的窗口过程及注册窗口类,也知道了DLL,哪还有什么可讲的呢?

16,470

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧