winapi

How do you convert bytes of bitmap into x, y location of pixels?

I have a win32 program that creates a bitmap screenshot. I am trying to figure out the x and y coordinates of the bmBits. Below is the code I have so far: UINT32 nScreenX = GetSystemMetrics(SM_CXSCREEN); UINT32 nScreenY = GetSystemMetrics(SM_CYSCREEN); HDC hdc = GetDC(NULL); HDC hdcScreen = CreateCompatibleDC(hdc); HBITMAP hb...

How can I receive mouse events when a wrapped control has set capture?

My WndProc isn't seeing mouse-up notifications when I click with a modifier key (shift or control) pressed. I see them without the modifier key, and I see mouse-down notifications with the modifier keys. I'm trying to track user actions in a component I didn't write, so I'm using the Windows Forms NativeWindow wrapper (wrapping the com...

WinAPI C - RunAsUser from REDMON_USER and REDMON_SESSIONID

I installed a PostScript printer driver and have setup REDMON (redmonnt.dll) for redirecting postscript output to my program. In my rather simple c program I capture the data from STDIN and I am able to successfully save it into a .ps file. The file looks OK. However, I want to start gsview.exe for viewing the file. If I call ShellEx...

Monitor clicks on application menu items such as open/save/copy/paste

I need to write a program that detects (and records statistics of) how often the user uses the mouse to activate application menu items (such as open, save, copy, paste). My question is: is there a way to detect that the user actually clicks one of these menu items? I have used Winspector to see what WM_xxx events are being fired, but ...

Why does DestroyWindow close my application?

I'v created a window after creating my main one but calling DestroyWindow on its handle closes the entire application, how can I simply get rid of it? it looks like this: BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; HWND fakehandle; hInst = hInstance; // Store instance handle in our global variable h...

Manually set UI Language?

Is there any way to manually or programmaticaly set the UI Language so that in my tests I can get a different results from GetUserDefaultUILanguage? Or anyone know the settings within Windows where I can change this? ...

Bona fide transiant windows with WinAPI?

I want to create a Window like when a context menu pops up or clicking the menubar. I want a Window that will be like this and that I can take over its paint event. Sort of like what is created when you select a sub tool in Photoshop. EDIT:I want to know how to create controls like the one that comes when you select a sub tool in Photo...

Undesired shortcut shown in the Recent Opened Programs in start menu on Windows 7

Hello all, My software has two .EXE files : A.exe and B.exe. After installed on Window 7, the shortcut to A.exe is always shown in the start menu. (I don't know if 'Start menu' is the correct name or not, what I mean is the area above 'All Programs'). The menu in my computer looks like: Getting Started Windows Media Center Calculat...

How do I correctly toggle the visibility of my toolbar button?

I try to modify code for IE toolbar button in visual c++. I manage to hide my toolbar button using, TB_HIDEBUTTON at run time. How to unhide it back in run time? Here is the code that Im currently modifying: void CRebarHandler::setButtonMenu2(){ TBBUTTONINFO inf; inf.cbSize=sizeof(inf); inf.dwMask=TBIF_STYLE; inf.fsStyle=BTNS_D...

Win32 lineout (audio) funnelling over network

I have a linux box hooked up to an amplifier via optical out, I use MPD to play music out through the amp. I also watch movies using a Popcorn Hour connected to the amp and to a projector. During daylight it's not really possible to use the projector so I want to watch TV programs on my Windows laptop, but still take advantage of the amp...

MessageBox not shown when opened processing WM_CLOSE from taskbar thumbnail close button

Trying to put up a "Do you want to save"-dialog when trying to close window with close-button in taskbar thumbnail in windows 7(with aero peek active). Using MessageBox() when processing WM_CLOSE does not work. MessageBox won't show until you move mouse cursor outside thumbnail so aero peek is disabled. Lots of applications have this b...

How to get spacing between characters printed using TextOut ?

I'm trying to calcuate size of each cell (containing text like "ff" or "a0"), so that 32 cells will fit into window by width. However, charWidth*2 doesn' represent the width of a cell, since it doesn't take spacing between characters in the account. How can I obtain size of a font so that 32 cells each is two chars like "ff" fit exactly...

How can I keep an event from being delivered to the GUI until my code finished running?

I installed a global mouse hook function like this: mouseEventHook = ::SetWindowsHookEx( WH_MOUSE_LL, mouseEventHookFn, thisModule, 0 ); The hook function looks like this: RESULT CALLBACK mouseEventHookFn( int code, WPARAM wParam, LPARAM lParam ) { if ( code == HC_ACTION ) { PMSLLHOOKSTRUCT mi = (PMSLLHOOKSTRUCT)lParam; ...

SHFileOperation FO_MOVE deletes a file if the destination drive is full

I had a piece of code which uses windows SHFileOperation function with FO_MOVE operation. Additional flags specified were FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT. A particular weird behavior was observed when the destination drive was full. In this case, MOVE could not place the file in destination folder but the source file was...

Window properties - how are they implemented?

I'm curious if there is anyone around here that has inside information on the implementation details of window properties (SetProp, GetProp, etc.) in Windows. SetProp @ MSDN GetProp @ MSDN For instance, how are storage and lookups done? ...

Win7 64/32 bits c# dll doubt

Hello, is it possible to build a c# dll and tlb files in a win7 64 bits computer and make it work in a win7 32bits computer? Thanks in advance :) Edit: I am using a c++ dll that calls the .tlb file generated in my c# COM interop dll proj. ...

Win32 C++ Import path based on OS?

I'm working with some legacy code that has an import like so: #import "C:\Program Files\Common Files\System\ado\msado15.dll" rename("EOF", "EndOfFile") The problem is, on a x64 machine the path for this import is in the 'Program Files (x86)' directory. Is there a preprocessor macro I can wrap around this to make it work on either? Ed...

How do I launch a winforms form from a DLL correctly?

There's another question similar to mine, but I wanted to gather some specifics: I want to create a DLL that is called from unmanaged code. When the unmanaged functions are called in the DLL, I want to collect information and show it in a kind of form. What I'd like to do is, when DllMain() is called, and the reason is DLL_PROCESS_A...

How can I deal with depressed Windows logo key when using `SendInput`?

My application synthesises keystrokes in other apps by using SendInput. This almost works, except that due to circumstances I cannot change, the left Windows key will always be physically depressed when sending the input. This means that if, for example, the keystroke being sent is the 'd' key, then Windows sees the keystroke as its Win+...

How might one cope with the ambiguous value produced by GetDllDirectory?

GetDllDirectory produces an ambiguous value. When the string this call produces is empty, it means one of the following: nobody has called SetDllDirectory somebody passed NULL to SetDllDirectory somebody passed an empty string to SetDllDirectory The first two cases are equivalent for my purposes, but the third case is a problem. If I...