一个关于 在form最小化时绘制form的小技巧.MS提供,但本人试了一下.为何不好使???????有兴趣进来一下

project 2002-07-31 11:45:39
Drawing a Minimized Window

You can draw your own minimized windows rather than having the system draw them for you. Most applications define a class icon when registering the window class for the window, and the system draws the icon when the window is minimized. If you set the class icon to NULL, however, the system sends a WM_PAINT message to your window procedure whenever the window is minimized, enabling the window procedure to draw in the minimized window.

In the following example, the window procedure draws a star in the minimized window. The procedure uses the IsIconic function to determine when the window is minimized. This ensures that the star is drawn only when the window is minimized.

POINT aptStar[6] = {50,2, 2,98, 98,33, 2,33, 98,98, 50,2};

.
.
.

case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);

// Determine whether the window is minimized.

if (IsIconic(hwnd))
{
GetClientRect(hwnd, &rc);
SetMapMode(hdc, MM_ANISOTROPIC);
SetWindowExtEx(hdc, 100, 100, NULL);
SetViewportExtEx(hdc, rc.right, rc.bottom, NULL);
Polyline(hdc, aptStar, 6);
}
else
{
TextOut(hdc, 0,0, "Hello, Windows!", 15);
}
EndPaint(hwnd, &ps);
return 0L;
You set the class icon to NULL by setting the hIcon member of the WNDCLASS structure to NULL before calling the RegisterClass function for the window class.


程序永远都走不到if (IsIconic(hwnd)) 里面??????????????????
我用此方法主要是为了想在form最小化到任务栏时在上面画些东西,诸位还有其它的办法吗?
...全文
37 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
project 2002-08-01
  • 打赏
  • 举报
回复
还是咱Delphi高手多.
大哥果然是高手.
当时我也想过这个问题,不过自己从来没这么做过,所以没试.
不自己注册窗口类可以吗?
有没有其它办法可以实现让我在form最小化时对其进行绘制?
为什么要把icon设为null才行呢?其原理是什么?
大哥有没有这方面的资料?最好是中文的.
你是怎样成为如此高手的?对这方面了解得这么深?
我应该如何学习呢?
我的QQ:110607569
你的可以给一个吗?以后要多向你学习噢?
eulb 2002-08-01
  • 打赏
  • 举报
回复
估计你没用set the class icon to NULL吧
这是在创建窗口类时赋值的
你可以自己注册一个窗口类,然后自己建立一个窗口
这样应该就可以了

比如:
var
wClass:TWndClass;

with wClass do
begin
hIcon := nil;
hCursor := LoadCursor(0, IDC_ARROW);
hbrBackground := COLOR_BTNFACE + 1;
style := CS_VREDRAW + CS_HREDRAW;
lpfnWndProc := @frmMainWindowProc;
lpszClassName := AClassName;
end;
RegisterClass(win.wClass);
win.hMain := CreateWindowEx(0, AClassName, ACaption,
(WS_VISIBLE or WS_OVERLAPPEDWINDOW) and (not WS_THICKFRAME),
ALeft, ATop, AWidth, AHeight, 0, 0,
Win.wClass.hInstance,
nil);
project 2002-08-01
  • 打赏
  • 举报
回复
If you set the class icon to NULL!
如何实现啊?
有具体点的代码吗?
40Star 2002-07-31
  • 打赏
  • 举报
回复
If you set the class icon to NULL
project 2002-07-31
  • 打赏
  • 举报
回复
这是MS网站上的原文.
你可试试下面的
procedure WndProc(var Message: TMessage); override;
procedure TForm1.WndProc(var Message: TMessage);
begin
inherited WndProc(Message);
case message.Msg of
WM_NCPAINT:
begin
if IsIconic(hwnd) then
Text = 'Form minimized'
else
Text = 'Form not minimized';
end;
end;
end;

另:我想每个form缩到下面后都画,用Application不行吧?繁请兄台明释
  • 打赏
  • 举报
回复
你上面写的是子窗体最小化时发生的事件
你在Application.OnMin...中写
ddvboy 2002-07-31
  • 打赏
  • 举报
回复
把代吗写全好吗?

5,939

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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