winapi

How do I hook in to a double-press of the Ctrl key?

What I'm looking for is functionality similar to Google desktop. When you hit Ctrl twice rapidly, a little search box pops up. I've tried using a fairly heavy keyboard hook class that I found somewhere, but that kept giving meunpredictable results (ie first time it would work, then I'd press Ctrl once, and it would raise the key presse...

How do I create a normal win32 edit control?

I'm trying to create an edit control with the regular 3D border around it (in the classic windows style, anyway), but it just has a 1px black border around it. Here is my CreateWindowEx call: return CreateWindowEx(0, "EDIT", "E:\\bk", WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT, 87, 81, 150, 1...

recursive file search

I'm trying to figure out how to work this thing out .. For some reason, it ends at a certain point.. I'm not very good at recursion and I'm sure the problem lies somewhere there.. Also, even if I checked for cFileName != "..", it still shows up at the end, not sure why but the "." doesn't show up anymore.. void find_files( wstring wr...

MFC separate groups of radio controls

I have added 8 radio buttons in my dialog layout in the resource manager, but I am having trouble separating them into 2 groups of 4 buttons. I have attempted to add a control variable, but I don't see the option of CButton available in the drop-down menu in the wizard. What would be the easiest method to accomplish this goal? ...

How to hide an external program's windows programmatically?

I want to hide an external application, ie. not the current application. I want to give the title of the application and it will be hidden. How can I do this programmatically? ...

Best way to close and wait for a child frame window using Win32/MFC

There are a few options here, probably, but what would you suggest to be the safest way to accomplish the following: I've got a child CFrameWnd with a parent = NULL (so that it can live a separate life from the main application, while the app is running, at least). I've got all those windows stored in a list. When the main app is closin...

Is there an API to set a NTFS ACL only on a particular folder without flowing permissions down?

In my environment, I have several projects that involve running NTFS ACL audit reports and various ACL cleanup activities on a number of file servers. There are two main reasons why I cannot perform these activities locally on the servers: 1) I do not have local access to the servers as they are actually owned and administered by anothe...

How to detect whether Windows is shutting down or restarting

I know that when Windows is shutting down, it sends a WM_QUERYENDSESSION message to each application. This makes it easy to detect when Windows is shutting down. However, is it possible to know if the computer going to power-off or is it going to restart after Windows has shutdown. I am not particularly hopeful, considering the document...

Shifting from .NET to Win32 development

I have been a .NET developer since I started coding. I would like to learn Win32 programming. Need advice on where to start. What are the best resources /books for learining Win32 programming. I know a bit 'college C++'. ...

Call to TMouse.GetCursorPos sometimes fails with "A call to an OS function failed"

On occasion my application gets the error below. Normally this happens when the user steps away from their desk leaving my program open. When they come back this error has appeared. TMouse.GetCursorPostion does not do anything except make the Windows API call to GetCursorPosition. Then it checks the return value and calls GetLastEr...

Detect window close outside of wndproc?

I am currently working on a win32 GUI app that does most of its work in the window thread. This thread can sometimes be blocked since it runs a script engine that can be suspended by an external script debugger (another process). This is not a problem most of the time as it is expected behavior. However, if the user tries to close the wi...

Simulate clicking a button in another window in C#

I'd like to close a dialog that pops up automatically, but I'm having some trouble getting it to work. My Win32 programming is a bit rusty after several years of limited usage. I'm using FindWindowEx to get handles to the dialog and the button I want to click. I was under the impression that sending a WM_COMMAND to the dialog, with the ...

How do I reset USB devices using the Windows API?

Do you know a way to use the Windows XP API to reset the USB bus? In other words, I'd like the OS to kick out any USB devices that are currently connected, and then auto-detect everything anew. I'm aware of devcon, and I suppose I could do system calls out to it, but I'm hoping for a direct call into the API. ...

Using CList in a multithreaded environment

I am using a CList in a multithreaded environment and I keep having problem with the GetHead method. I have one thread that add data to the list, and an other thread who read and remove data from the list. Here is the reading part : value_type get_next() { T t; if(!queue.IsEmpty()) { t = queue...

How to draw a window to a memory device context?

In my app the user double-clicks on a table row to open a dialog window. The problem is that the window is instantly displayed - I want to make the window appear to 'jump out' of the table row (in the same way that windows 'jump out' from the task bar). To do this I need to draw the dialog window to a memory device context - how can I ...

creating a bitmap pattern for a window's HBRUSH

Well, I sort of want to have sort of a faint striped pattern across a window... Just, 'cause it'd look nice. Anyways, I know I can just make a hatched brush, like so: however, I can only set the foreground color, and I don't know how to make the background not white (just use the default window color). I was poking around MSDN trying ...

How do I change the background of a STATIC win32 control?

If the parent form of a (text) static control has a pattern on its background, then the area around the static control is an ugly blotch of solid color. How can I paint the background of the static control with the same pattern that its parent window uses? I've tried this, SetClassLong(retval , GCL_HBRBACKGROUND, (LONG)stripes); w...

How to tell if Windows Taskbar's "autohide" is enabled?

How can I tell via a Delphi program if the Windows Explorer Taskbar is set to Autohide? ...

Need an easy WinAPI grid in C

I am looking for a grid control that can be controlled via WinAPI messages. I have tried the BabyGrid from CodeGuru but it is very slow when it comes to displaying on large screen. Anyone know of a good one? ...

Getting the containing window of a known control using the control's handle

This is probably an easy one for a GUI programmer, which I'm not... In a tool I'm working on (GUI "spy" for internal use) I have the handle of a control the user has chosen. I would like to get the handle of the window that contains the control, in order to sent it a certain message. Now: The control could be of various types, and po...