setwindowlong

学习:MFC子类化

删除回忆录丶 提交于 2020-02-12 19:10:16
窗口子类化:是创建一个新的窗口函数代替原来的窗口函数。 简单说来,子类化是靠拦截Windows系统中的某些消息来自己进行处理。 自己实现的是子类化一个编辑框,对编辑框输入的内容进行限制 只允许0~9、空格、一个点 定义一个CEditDemo头文件 /* 逻辑顺序: 1、在窗口的初始化函数中得到想要子类化的窗口句柄 2、Attach函数中利用SetWindowLong替换自己要的窗口函数,并且再定义一个指针来保存SetWindowLong返回来的初始的窗口函数 3、定义自己想要的窗口函数NewProc,先判断uMsg是否WM_CHAR,为想要子类化的消息事件,再利用传过来的wParam和lParam来进行详细的字符判断,在进行操作 4、在窗口函数中进行处理完,还需要重新调用初始的窗口函数,其他的默认操作还需要交给初始的窗口函数进行处理 5、最后还需要重写恢复窗口函数 */ #pragma once class CEditDemo { public: CEditDemo(); ~CEditDemo(); bool Attach(HWND hWnd); bool Detach(HWND hWnd); long OldProc; protected: static LRESULT APIENTRY NewProc( HWND hwnd, // handle to window UINT

How do I call SetWindowLong() in the 64-bit versions of Windows?

我的未来我决定 提交于 2019-12-22 01:39:50
问题 In the header file WinUser.h , there is a part in which the constants of the second parameter of SetWindowLong() are defined. // ... #define GWL_WNDPROC (-4) #define GWL_HINSTANCE (-6) #define GWL_HWNDPARENT (-8) #define GWL_STYLE (-16) #define GWL_EXSTYLE (-20) #define GWL_USERDATA (-21) #define GWL_ID (-12) #ifdef _WIN64 #undef GWL_WNDPROC #undef GWL_HINSTANCE #undef GWL_HWNDPARENT #undef GWL_USERDATA #endif /* _WIN64 */ #define GWLP_WNDPROC (-4) #define GWLP_HINSTANCE (-6) #define GWLP

Win8 - Winforms mouse transparent form with clickable controls in it

限于喜欢 提交于 2019-12-11 03:45:33
问题 I'm trying to make a mouse transparent form in win8 and winforms, that contains controls that are clickable. I'm able to make the form mouse transparent, using this code int initialStyle = GetWindowLong(this.Handle, -20); SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20); (on win8 the WndProc approach does not work) But when I make the form mouse transparent, the controls that are contained in this form are also mouse transparent What can I do? 回答1: You can create a Form and set

SetWindowLong函数GetWindowLong函数

南楼画角 提交于 2019-12-10 13:23:15
这两个函数具体应用如下:SetWindowLong函数GetWindowLong函数 Delphi窗口化游戏 var Thwnd:HWND;//声明变量 句柄变量 devmodel1:DEVMODE;//屏幕分辨率变量 style,exstyle:longint;//窗口属性变量 begin //得到游戏句柄 Thwnd:findwindow('CLIENT',nil); //设置分辨率 if EnumDisplaySettings(0,0,devmode1)then   begin     devmode1.dmPelsWidth:1024; devmode1.dmPelsHeight:=768; devmode1.dmBitsPerPel:=32; devmode1.dmDisplayFrequency:=75;     ChangeDisplaySetting(devmode1,0); end; //得到窗口原来的属性 style:=GetWindowLong(Thwnd,GWL_STYLE); //定义新属性 style:=WS_OVERLAPPEDWINDOW or WS_VISIBLE; //更改窗口属性 SetWindowLong(Thwnd,GWL_STYLE,style); //得到窗口扩展属性 exstyle:=GetWindowLong(Thwnd,GWL

c# 隐藏窗口在ALT+TAB中

北战南征 提交于 2019-12-07 11:37:44
winform: protected override CreateParams CreateParams { get { const int WS_EX_APPWINDOW = 0x40000; const int WS_EX_TOOLWINDOW = 0x80; CreateParams cp = base.CreateParams; cp.ExStyle &= (~WS_EX_APPWINDOW); // 不显示在TaskBar cp.ExStyle |= WS_EX_TOOLWINDOW; // 不显示在Alt-Tab return cp; } } WPF: #region Window styles [Flags] public enum ExtendedWindowStyles { // ... WS_EX_TOOLWINDOW = 0x00000080, // ... } public enum GetWindowLongFields { // ... GWL_EXSTYLE = (-20), // ... } [DllImport("user32.dll")] public static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex); public static IntPtr SetWindowLong

Detect / Hook Window Move/Drag of other external processes

假装没事ソ 提交于 2019-12-03 20:21:46
问题 What is the best way to Detect Window Move/Drag of other Processes? In Windows7 64-bit I'm currently investigating Global Hooks from a DLL using C++ & C#. It's a pain as it doesn't want to work properly. I've gotten some success with keyboard and mouse hooks. but for window messages I've just got no idea whats wrong. this is the code in my .dll file #include <windows.h> #include <iostream> #include <stdio.h> HINSTANCE hinst; #pragma data_seg(".shared") HHOOK hhk; WNDPROC realProc; #pragma

SetWindowLong

匿名 (未验证) 提交于 2019-12-02 23:57:01
Delphi SetWindowlong 设置窗口属性 SetWindowLong函数介绍。 SetWindowLong Unicode 函数原型 LONG SetWindowLong(hwnd,nIndex,lNewLong) HWND hwnd; /* handle of window */ int nIndex; /* offset of value to set */ LONG lNewLong; /* new value */ 函数说明 SetWindowLong函数修改给定窗口的一个属性。该函数还在给定窗口的附加窗口内存中 的指定偏移量处设置一个32位(长)值。 参数详解 hwnd 标识窗口,并且间接标只出该窗口的属的窗口类。 nIndex 指定一个距离要设置的值的以0为基值的偏移量。有效的偏移量范围最小为0,最大为附 加窗口内存的总字节数减为4,注:整数为四个字节;例如:若附加内存被指定为12个或 更多个字节,值8将是第3个长整数的索引值。要设置其它值,则应指定下列值之一: 值 动 作 ============================================================================ GWL_EXSTYLE 设置新的扩展窗口风格。 GWL_STYLE 设置新的窗口风格 GWL_WNDPROC 为窗口过程设置新地址。

Removing window border?

我与影子孤独终老i 提交于 2019-11-27 03:03:55
I have a window with a solid border around it. How can I remove the border (all of the non-client area) by using SetWindowLong and GetWindowLong ? John Knoeller In C/C++ LONG lStyle = GetWindowLong(hwnd, GWL_STYLE); lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU); SetWindowLong(hwnd, GWL_STYLE, lStyle); WS_CAPTION is defined as (WS_BORDER | WS_DLGFRAME). You can get away with removing just these two styles, since the minimize maximize and sytem menu will disappear when the caption disappears, but it's best to remove them as well. It's also best to remove

How do I pinvoke to GetWindowLongPtr and SetWindowLongPtr on 32-bit platforms?

天大地大妈咪最大 提交于 2019-11-26 20:56:57
I want to P/Invoke to GetWindowLongPtr and SetWindowLongPtr , and I'm seeing conflicting information about them. Some sources say that, on 32-bit platforms, GetWindowLongPtr is just a preprocessor macro that calls GetWindowLong, and GetWindowLongPtr doesn't exist as an entry point in user32.dll. For example: The pinvoke.net entry for SetWindowLongPtr has a static method that checks IntPtr.Size and then calls either SetWindowLong or SetWindowLongPtr, with a comment saying that "legacy OSes do not support SetWindowLongPtr". There's no explanation of what is meant by "legacy OSes". An answer on

Removing window border?

怎甘沉沦 提交于 2019-11-26 10:22:49
问题 I have a window with a solid border around it. How can I remove the border (all of the non-client area) by using SetWindowLong and GetWindowLong ? 回答1: In C/C++ LONG lStyle = GetWindowLong(hwnd, GWL_STYLE); lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU); SetWindowLong(hwnd, GWL_STYLE, lStyle); WS_CAPTION is defined as (WS_BORDER | WS_DLGFRAME). You can get away with removing just these two styles, since the minimize maximize and sytem menu will