登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> CLQ工作室开源代码 >> 主题: [windows api]WS_CLIPSIBLINGS 解决绘画到同级 windows 上的问题     [回主站]     [分站链接]
标题
[windows api]WS_CLIPSIBLINGS 解决绘画到同级 windows 上的问题
clq
浏览(338) + 2022-01-15 19:15:01 发表 编辑

关键字:

[2022-01-15 19:19:40 最后更新]
[windows api]WS_CLIPSIBLINGS 解决绘画到同级 windows 上的问题

在移植跨平台框架时意外发现会在 window 的 WM_PAINT 中绘制到别的同级 window 上,搞了半天才知道要加 WS_CLIPSIBLINGS 标志。

----------------------------------------------------------------
// The class is registered, let's create the program
hwnd = CreateWindowEx (
0, // Extended possibilites for variation
szClassName, // Classname
TEXT("cf5t1"), // Title Text

//这个参数其实最重要
//WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP | WS_TABSTOP | ES_WANTRETURN, //WS_OVERLAPPEDWINDOW, // default window
//WS_CHILD | ES_WANTRETURN, //WS_OVERLAPPEDWINDOW, //default window
WS_CHILD | ES_WANTRETURN | WS_CLIPSIBLINGS, //WS_OVERLAPPEDWINDOW, //default window
//WS_CLIPSIBLINGS 风格非常重要,如果没有的话会在 wm_paint 的时候画到别人上面


0, //x
0, //y
90, //width
50, //height

parentView, //HWND_DESKTOP, // The window is a child-window to desktop //父窗口
NULL, // No menu
hThisInstance, // Program Instance handler
NULL // No Window Creation data
);

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


参考 //https://blog.csdn.net/cde7070/article/details/7790446
// CreateWindow 创建edit不能使用中文输入的解决办法
// CreateWindowEx(NULL,
// "EDIT","",
// WS_CHILD|WS_VISIBLE,
// 10,10,
// 300,300,
// hwnd1,
// (HMENU)1001,
// hInstance,
// NULL);
// 使用如上代码时,会出现在切换成中文输入法时,无法看到输入法。
// 解决办法:便是在创建父窗口时,使用WS_CLIPSIBLINGS。



clq
2022-01-15 19:19:40 发表 编辑

d7 的代码如下(d7虽然老,但是是最原汁原味的 windows api 所以一定要看看):

procedure TWinControl.CreateParams(var Params: TCreateParams);
begin
  FillChar(Params, SizeOf(Params), 0);
  with Params do
  begin
    Caption := FText;
    Style := WS_CHILD or WS_CLIPSIBLINGS;
    AddBiDiModeExStyle(ExStyle);
    if csAcceptsControls in ControlStyle then
    begin
      Style := Style or WS_CLIPCHILDREN;
      ExStyle := ExStyle or WS_EX_CONTROLPARENT;
    end;
    if not (csDesigning in ComponentState) and not Enabled then
      Style := Style or WS_DISABLED;
    if FTabStop then Style := Style or WS_TABSTOP;
    X := FLeft;
    Y := FTop;
    Width := FWidth;
    Height := FHeight;
    if Parent <> nil then
      WndParent := Parent.GetHandle else
      WndParent := FParentWindow;
    WindowClass.style := CS_VREDRAW + CS_HREDRAW + CS_DBLCLKS;
    WindowClass.lpfnWndProc := @DefWindowProc;
    WindowClass.hCursor := LoadCursor(0, IDC_ARROW);
    WindowClass.hbrBackground := 0;
    WindowClass.hInstance := HInstance;
    StrPCopy(WinClassName, ClassName);
  end;
end;


总数:1 页次:1/1 首页 尾页  
总数:1 页次:1/1 首页 尾页  


所在合集/目录
windows 更多
windows api 更多



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1