winapi

How do I get mnemonics in TrackPopupMenu?

I have a win32/MFC application with a context menu that I build programatically: CPoint pt; GetMenuPopupPos(&pt); CAtlString csItem = _T("&Example"); CMenu menu; menu.CreatePoupMenu(); menu.AppendMenu(MF_STRING, IDM_EXAMPLE_COMMAND, csItem); menu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_LEFTBUTTON, pt.x, pt.y, this, NULL); I've omitted the ...

Let my MFC dialog receive keystroke events before its controls (MFC/Win32 equivalent of WinForms "KeyPreview")

I have an MFC dialog containing a dozen or so buttons, radio buttons and readonly edit controls. I'd like to know when the user hits Ctrl+V in that dialog, regardless of which control has the focus. If this were C#, I could set the KeyPreview proprety and my form would receive all the keystrokes before the individual controls - but how...

Any documentation for Win32 ShellEx StorageHandler?

I'm currently poking around with a new archive format and was interested in implementing a shell extension like the native Zip support that Windows XP has. This appears to be done by registering a shell extension that implements a StorageHandler. Problem is that according to MSDN, this handler doesn't exist. I've tried Googling variou...

How to track keyboard input and bypass SendInput

I'm developing an application which needs to count user keystrokes. It works fine however user can trick the app with SendInput() WINAPI function. Is it any way to differentiate between keystrokes made by real user and those sent via SendInput? ...

Getting a list of user profiles on a computer in C++ Win32

What is the best way to enumerate all of the user profiles on a computer? I know how to get the currently logged in user profile, and I know how to get the "all user" profile. But I'd like to get a list of each and every profile on the computer. ...

Replacing the Start Menu

I want to make my own Start Menu replacement and I am trying to figure out what approach to use. There are a number of ways the Start Menu is activated: click on it, hit windows key, hit ctrl+esc keys or tab until it gets focus and hit the space or enter key. I know enough about win32 to do each one of these separately and I could figur...

Programmatically maximize an external application's window (vb .net)

I have an application right now that starts a process, then opens a file associated with that process (system.diagnostics.process.start("WM.exe")), however, the way they save, there is a window within a window. It's like in photoshop cs3 when you have many windows within the big window of the application. Right now I use an api call to f...

GetDesktopWindow alternative when running as service

Hi, I am trying to test my WinForm app as part of the build (which runs as a service). I am using GetDesktopWindow and EnumChildWindows to find the controls I am interested in. This works perfectly when I run it in interactive session from the console, debugger, etc. but fails to find any control when run as part of the build. What can I...

What does .NET give me, that Win32 does NOT?

What would the usage of .NET give me, that i don't have using Win32 - and sometimes maybe googling for some 50-100 Lines of code i can reuse? I am developing Win32 since it exists (> 15 years). Its straight forward and very robust, although sometimes it needs some more calls than you'd expect, and of course you need to keep track of han...

What error codes can occur with CopyFileEx?

I'm writing some C++ code that needs to call the CopyFileEx function. The documentation for CopyFileEx, like most other WIN32 functions, says: If the function fails, the return value is zero. To get extended error information, call GetLastError. Which is all well and good - however does anyone know where I can find a list of the error...

Adding external library into Qt Creator project

Have created a simple library using vc6 compiler which defines a class Sum with a method add which takes two parameters and retruns an int, I have included this in my QT application in the pro file as win32:LIBS +=D:\nest_qt_dev\SumLib\Debug\SumLib.lib However I get an undefined reference to `CSum::Add(int, int)' error. My Library Co...

How can I ensure that a dynamically created Form will be a child window in the process tree of windows?

Hi, I am still trying to test my WinForm application, however some of the testing tools don't work because the custom dialog forms I dynamically create are not child windows in the window tree (in Win32 api sense). I am using Spy++ to browse and search for windows. If I use the Finder Tool on these forms, some of them are found as direc...

Maximize child window of other application (VB .Net)I'

I'v used findwindowex to find the child window. I used findwindow to find the big application, and I found that with spy++. I know that it is the right one because I'm able to sendkeys to it and they work. I'm trying to maximize it but it does not work. I tried to do the showwindow call and use the 3 costant to maximize it, with no luck....

Maximize an MDIChild of another application VB .Net

I'm making an appication that needs to maximize the window of another application. In Spy++, the way it works is -> "Working Model - Untitled1" -> "MDICloient" -> "Untitled1" This is what the tree view looks like. I need to maximize Untitled1, but I'm not sure how. I tried findwindow "Working Model - Untitled1" and then used get and se...

Enable a control of another application with User32 (vb .net)

I was wondering if there was a function in user32 that could enable a hwnd control if it is disabled (grayed out) If I know the handle then can I do this? Also, if it is a menuitem, can it be done too? Thanks ...

Find handle of another application's menu (vb .net)

I want to make a program that will disable menu items of an appication for parental control using user32's enablewindow function. Using spy++ I can find buttons, controls etc, but I cannot seem to find menus and menu items. How could I find the handle for these so I could disable them when the user trys to click on them? Thanks ...

How can I get meaningful error info from OpenGL on Windows

I'm trying to create a GL context, and the call fails, returning a null pointer. According to MSDN, when wglCreateContext fails, you get the reason why from GetLastError. Except that GetLastError gives me a number, which isn't all that informative. Again according to MSDN, you can get a descriptive string out of the GetLastError code ...

Get size and location of childwindow with user32

If I know the hwnd of a window, could I get it's position and location based on my screen size. (I mean, size and location in pixels) What I want to do is capture the screen, but only capture the handle's area. Thanks ...

SwitchToThread vs Sleep(1)

I'm wondering what's the actual difference between calling Thread.Sleep(1) and calling SwitchToThread (if we ignore that it's currently not exposed by the BCL). Joe Duffy mentions in his post that: "The kernel32!SwitchToThread API doesn't exhibit the problems that Sleep(0) and Sleep(1) do." (regarding the scheduler's behavior) Why...

Fastest way to write string on Windows?

What would be the absolute fastest possible way to write a string to the standard/console output on Windows? I'm interested in the solution for both null- and non-null-terminated strings. ...