问题描述
我希望使用鼠标移动获得鼠标下方的像素颜色,并希望使用gdi将该颜色填充为静态控件背景颜色或矩形。
我不是常规的win32程序员。
我搜索并获得其他来源的所有回复以使用消息WM_CTLCOLOREDIT。
但是我的情况是动态的。
我刚试过以下但是没有用......
HWND hwnd,cbox;
COLORREF cboxcolor;
cbox = CreateWindow( STATIC, ds,WS_CHILD | WS_VISIBLE, 10 , 50 , 50 , 50 ,hwnd, 0 ,GetModuleHandle( 0 ), 0 );
cboxhdc = GetDC(cbox);
cboxcolor = RGB( 255 , 2 , 255 );
SetBkColor(cboxhdc,cboxcolor);
当我检查GD功能时,我认为需要创建画笔..那么多......
太多的线条认为设置颜色应该简单直接而不是懒得去做。但是...它有太多的选择...
因此想到使用ExtTextOut ......还没有使用它。
想要确定哪条路可走?
以下哪一项涉及的处理较少或因其他原因而有所好处.. 。
1.创建静态控件并在鼠标移动时更改背景颜色。如果可能的话
2.创建一个有界区域并填充颜色。我觉得很乏味。
3.使用ExtTextOut ...
?
过了一会儿,我找到了一个解决方案,回答了我自己的问题。如果有人想在这里添加更多或更正我的话请继续...
I wanted to get the pixel color beneath the mouse using mouse move and wanted to fill that color into a static controls background color or a rectangle using gdi.
I am not a regular win32 programmer.
I searched and got all the replies form others sources to use the message WM_CTLCOLOREDIT.
But my case is dynamic.
I just tried the following but it did not work...
HWND hwnd, cbox; COLORREF cboxcolor; cbox = CreateWindow("STATIC", "ds", WS_CHILD|WS_VISIBLE, 10, 50, 50, 50, hwnd, 0, GetModuleHandle(0), 0); cboxhdc = GetDC(cbox); cboxcolor = RGB(255,2,255); SetBkColor(cboxhdc, cboxcolor);
and when i checked GD functions i assume that brushes needed to be created ... so and so...
that was too many lines thinking that setting a color should be simple and straight forward yet not lazy to do it. but... its like too many options...
So thought of using ExtTextOut... haven't used it.
Want to make sure which way to go?
Which one of the following involves less processing or good for what ever other reason...
1. Create a static control and change the background color on mouse move. if possible
2. Create a bounded area and fill color. which i feel tedious.
3. using ExtTextOut...
?
After a while i found a solution and had replied to my own question. if anybody would like to add more or correct me of anything here then please go on...
这篇关于使用GDI或控件填充矩形区域的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!