how to set win32 api c++ button background color and text color?

im using simple button in win32 application and i like to change its color and text but i can't find from all searching in google how to do it. i have this code that represent a button: this is in the rc file : LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG1 DIALOG 0, 0, 273, 209 STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU CAPTION "Win32 demo" FONT 8, "Ms Shell Dlg" { DEFPUSHBUTTON "My Button1 ", IDOK, 59, 176, 69, 14 PUSHBUTTON "Log Off", IDC_BUTTON1, 155, 175, 54, 14 } and in the main cpp file i only triger simple Massegebox

2021-07-13 15:56:10    分类:问答    c++   winapi   button   background-color

can I have main window procedure as a lambda in WinMain?

I have a simple window application with declared main window callback procedure: WNDCLASSEXW wcx; /* ... */ wcx.lpfnWndProc = MainWndProc; and after the WinMain I declared LRESULT CALLBACK MainWndProc(HWND mainWindow, UINT msg, WPARAM wparam, LPARAM lparam) { /* ... */} and all is working ok, but I wonder is it possible to have this MainWndProc as a lambda inside WinMain ?

2021-07-13 14:22:34    分类:问答    c++   winapi   c++11   lambda

Why the irrelevant code made a difference?

I am thinking to make a progress bar with python in terminal. First, I have to get the width(columns) of terminal window. In python 2.7, there is no standard library can do this on Windows. I know maybe I have to call Windows Console API manually. According to MSDN and Python Documentation, I wrote the following code: import ctypes import ctypes.wintypes class CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): _fields_ = [ ('dwSize', ctypes.wintypes._COORD), ('dwCursorPosition', ctypes.wintypes._COORD), ('wAttributes', ctypes.c_ushort), ('srWindow', ctypes.wintypes._SMALL_RECT), (

2021-07-13 10:51:42    分类:问答    python   windows   winapi   ctypes

Are the GDI functions BitBlt and StretchBlt hardware accelerated in Win32?

I can't seem to get a definite answer to this via searching. Are the Win32 blitting operations hardware accelerated (GDI, not GDI+). I don't know how these functions interface with the graphics driver. Is there any function call to verify this functionality, like ?GetCaps? for a specific graphics device (win32 graphics device) to see if these functions are receiving hardware acceleration?

2021-07-13 10:28:22    分类:问答    winapi   bitmap   hardware   gdi   bitblt

Get STARTUPINFO for given process

Is it possible to get the startup information of another running process? I want to find out the cmd line arguments, if it should be run minimised/maximised, start in directory, run as admin, etc.

2021-07-13 10:17:39    分类:问答    c   winapi

WS_VSCROLL, CreateWindow style works, SetWindowLong doesnt

When i do wnd = CreateWindow("EDIT", 0, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN, x, y, w, h, parentWnd, NULL, NULL, NULL); everything is fine, however if i remove the WS_VSCROLL and WS_HSCROLL then do the below, i do not get them thus have incorrect window. Why? Not only do i get an incorrect window it is unusable if both WS_VSCROLL and WS_HSCROLL are missing style = WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN; SetWindowLong(wnd, GWL_STYLE, style);

2021-07-13 09:48:07    分类:问答    winapi   controls   scrollbar   styles

Win32 更改为二进制模式孩子的标准输出(管道)(Win32 changing to binary mode child's Stdout (pipe))

问题 你好,这个伟大的社区, 当使用管道将孩子的标准输出重定向到文件时,我在自动转换('\n') 0x0A到('\n\r') 0x0D 0x0A时遇到问题,孩子的输出是 bytes 而不是 text 。 首先,我使用了这些示例 MSDN-Creating a Child Process with Redirected Input and Output 和 http://support.microsoft.com/kb/190351),现在我有了这个基本应用程序,它创建一个管道并重定向子进程STDOUT 到二进制文件。 所有这些都在 Visual C++ 6.0 中的 Win32 控制台应用程序中(是的,它很旧,但它是必需的)。 #define BUFSIZE 256 HANDLE g_hChildStd_OUT_Rd = NULL; HANDLE g_hChildStd_OUT_Wr = NULL; int _tmain(int argc, TCHAR *argv[]) { SECURITY_ATTRIBUTES saAttr; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; if (

2021-07-13 05:06:46    分类:技术分享    c++   winapi   visual-c++

What's with these g++ “multiple definition” errors?

I'm in the early stages (read:just started yesterday) of a project, and I'm setting up my initial makefile. It's very simplistic. Here's the full contents of the file: all: main.o resource.o g++ -o output.exe main.o resource.o main.o: main.cpp main.h resource.h g++ -mwindows -o main.o main.cpp resource.o: resource.rc windres resource.rc resource.o clean: rm *.o At this point I think it's important to mention that I'm working on Windows, so I'm doing all of this in either Powershell with MinGW g++ 4.5.2 or else with Cygwin and g++ 3.4.4 (I've tried both; same errors). Without printing the

2021-07-13 04:59:24    分类:问答    c++   winapi   makefile   g++   mingw

WM_ENTERSIZEMOVE / WM_EXITSIZEMOVE - 使用菜单时,并不总是配对(WM_ENTERSIZEMOVE / WM_EXITSIZEMOVE - when using menu, not always paired)

问题 为了防止我的应用程序在用户移动窗口时更改窗口内容,我捕获消息WM_ENTERSIZEMOVE / WM_EXITSIZEMOVE并在消息之间暂停应用程序。 但是,有时会发生我收到WM_ENTERSIZEMOVE但根本没有WM_EXITSIZEMOVE情况。 一种再现是: 打开窗口菜单点击尺寸不要调整窗口大小,而是点击进入窗口 注意窗口从未收到任何WM_EXITSIZEMOVE 。 在检查其工作原理时,我还检查了 Microsoft DirectX 示例,并且发现了同样的问题。 按照上面的重现步骤进行操作后,示例应用程序看起来已经冻结了(我刚刚使用 2009 年 3 月 SDK 中的 BasicHLSL 示例进行了尝试)。 应用程序将如何对此做出响应? 是否还有其他一些条件可以终止“移动或调整模态循环” ? 回答1 我知道这已经很晚了,但它可能仍然对您有帮助 - 它可能会帮助其他在搜索中找到它的人,就像我一样。 似乎在您提到的情况下,“取消”调整大小时会发送 WM_CAPTURECHANGED 消息。 经过广泛的测试,这似乎总是在 WM_EXITSIZEMOVE 是(或应该是!)之前发送,并且在 WM_ENTERSIZEMOVE / WM_EXITSIZEMOVE 之间没有其他阶段。 WM_CAPTURECHANGED 消息也会在其他各种时间发送,因此您应该只在 WM

2021-07-13 04:56:00    分类:技术分享    c++   winapi

EnumChildWindows 还是 FindWindowEx?(EnumChildWindows or FindWindowEx?)

问题 我可以选择使用任何一种 API EnumChildWindows 或 FindWindowEx。 任何建议哪个api更好地面向性能? FindWindowEx 是否在内部使用 EnumChildWindows 来获取特定窗口的句柄? 回答1 这在很大程度上取决于您的场景。 FindWindowEx 函数用于在窗口中搜索具有特定类和可选的特定文本段的窗口。 EnumChildWindows 函数只是用来枚举子窗口。 我认为性能应该是你最后关心的问题。 首先是选择正确的 API。 如果您确实要搜索特定类的窗口,则使用 FindWindowEx,否则使用 E​​numChildWindows。 使用 EnumChildWindows 实现与 FindWindowEx 具有相同行为的函数是没有意义的。 现在在选择正确的解决方案后,如果分析器明确告诉您该解决方案太慢,那么您应该考虑手动实现更具体的功能。 以前不是。

2021-07-13 04:49:01    分类:技术分享    c++   winapi