winapi

Can we use a timer for itself?

Actually this is what i want to do; When a condition appears, my program will close itself and after five minutes it will re-open. Is it possible with only one .exe -by using any OS property-? I do it with two .exe if (close_condition){ //call secondary program system ("secondary.exe"); return (0); } and my secondar...

Get localized date time string and time zone name in differnet languages on windows.

Is there any windows API or language feature (C++,C#) to get the time, date and time zone name in localized format for different languages? EDIT: In C# I can get the localized strings for date and time, but it seems TimeZoneInfo doesn't have localized strings. I also didn't find it in the registry. Most probably you need to translate ti...

Display change notification

Is there any way to know that computer monitor was changed to another one? I need to reset display settings to default, if new one connected. ...

How do you set hotspot co-ordinates on a Windows cursor generated from an icon file?

Hello. I'm setting a custom cursor on my app from an icon file, but the click point is at the wrong co-ordinates. I'm setting the cursor with SetClassLongPtr(hwnd, GCL_HCURSOR, reinterpret_cast<LONG_PTR>cursor) where cursor is the result of; LoadImage( NULL, "some_path/cursor.ico", IMAGE_ICON, //also tried IMAGE_CURSOR...

how do I launch another process in XP compatibility mode?

Our application requires HASP SRM device driver to be installed in order for ours to install and run. At this time, only their 5.50 drivers work consistently on all tested platforms (both their 5.75 (official) and 5.86 (beta) drivers crash on about 1 in 3 computers tested). Hence, their 5.50 drivers are good, anything else currently av...

How to set the size of the Non-client area of a Win32 window (native)

How to set the size of the Non-client area of a Win32 window (native). What I want is to make the CAPTION/TITLE bar THICKER. I've read and been told that I should handle WM_NCCALCSIZE but I can't find nothing clear on the documentation. From MSDN: WM_NCCALCSIZE Notification The WM_NCCALCSIZE message is sent when the size and posi...

What is the cleanest way to create a timeout for a while loop?

Windows API/C/C++ 1. .... 2. .... 3. .... 4. while (flag1 != flag2) 5. { 6. SleepEx(100,FALSE); //waiting for flags to be equal (flags are set from another thread). 7. } 8. ..... 9. ..... If the flags don't equal each other after 7 seconds, I would like to continue to line 8. Any help is appreciated. ...

Trying to show a balloon notification with Ruby

I'm trying to make a little class in ruby allowing me to make a system tray icon and use the notification balloons. But I'm having problems using structs with Win32API calls. http://www.ruby-forum.com/topic/18102 Shell_NotifyIcon Function NOTIFYICONDATA Struct Heres the code I have now, all it does is add an icon to the system tray: r...

Show a custom calendar dropdown with a derived DateTimePicker class

My goal is to create a custom DateTimePicker class in .NET 2.0, which shows a custom calendar dropdown instead of the Windows default calendar popup. By observing Windows messages (see attached code), I am able to find and hide/close the calendar window after creation. However, a problem remains: After the calendar window is closed, so...

Trap WM_SETFOCUS message

I want to trap WM_SETFOCUS messages on all the current windows. Whats the best way to do that. I think SetWidnwosHookEx can be used to for this purpose. Can it be used with WH_CALLWNDPROC or WH_MSGFILTER ? Also its mentioned that hook procedure must be in separate dll. Is it required. Can I not have hook procedure in same dll which ins...

Does drawing over an hdc using gdi+ results in a premultiplied by alpha bitmap ?

I'm trying to draw some bitmap on a CImage object using GDI+ DrawImage. The resulting CImage bitmap seems to be premultiplied by alpha but I can't find any mention of that in the msdn documentation. What happens when I draw using DrawImage over an CImage HDC ? ...

How can I get the Windows last reboot reason

I'd like to know what is the Windows API function (if any exists) that provides information about the last Windows reboot source. There are three main possible causes: The computer crashed on a blue screen A user or a program shutdown/restarted the computer A power lost The more details I can get the better. However, I need to know a...

how to get window os system idle time using ruby?

I have a ruby script. I want to know how long the system has been idle (i.e. no user interaction - the time screen saver activation is based upon). I believe I can do this in ruby via win32api using user32.dll and GetLastInputInfo, but I can't figure out how... can anyone can help me? . ...

button keyboard focus issues

How would one prevent the little dotted square that appears on a button when it has the keyboard focus in a dialog. (w/ apologies for the technical jargon). At one point I hacked together a solution by subclassing a button WindowProc and subverting some windows messages, but wanted to know the correct way. There's actually a problem ...

Getting screenshot of a child window running OpenGL in it (Windows)

I have a main window with children. I need to take screenshots programmatically to crop and draw them back on my main window. The way I do this is: HDC hDC = GetWindowDC(hWnd); HDC memDC = CreateCompatibleDC(hDC); HBITMAP memBM = CreateCompatibleBitmap(hDC, Width, Height); HBITMAP OldBM = (HBITMAP)::SelectObject(memDC, memBM ); BitBlt(m...

wxWidgets program I developed has two entries in the process manager. Is this normal or a bug?

I'm developing a program in wxwidgets that has one worker thread that does COM stuff. I just noticed that it has two entries in the task manager. Looks like myapp.exe*32 myapp.exe*32 Is this duplicate entry normal? I noticed most other processes don't. Hmm. What could cause this? I'm using Windows 7 Ultimate 64 bit. ...

Help troubleshoot a consistently repeatable mod_perl2 / $SIG{__DIE__} bug

This is mod_perl2 on Apache 2.2, ActiveState Perl 5.10 for win32. I override $SIG{__DIE__} and turn on DBI's RaiseError flag, which AFAICT from the docs, should call my override when a database call fails. It seems to almost always, except in one case, and I can't understand why. My script has an our $page variable, and being mod_perl...

After hooking hook procedure is called infinitely

I have hooked WM_SETFOCUS message by calling API hhookCallWndProc = SetWindowsHookEx(WH_CALLWNDPROC, HookCallWndProc, hInst, threadID); Hook Procedure is extern "C" LRESULT _declspec(dllexport) __stdcall CALLBACK HookCallWndProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode == HC_ACTION) { CWPSTRUCT* info ...

How can an application display an object on the Windows taskbar?

There are several applications around that display objects on the Windows taskbar but do no implement the IDeskBand interface. For example, the Lenovo batter meter and Notebook BatteryInfo. For example: In the picture above, the object on the taskbar is put there by the application and disappears when the application closes. This i...

What should expericenced Unix programmer to be aware of using Microsoft Tools?

I come from UNIX world, I'm quite familiar with Linux, Solaris, Cygwin and MinGW development. Recently I ported one of my big projects (cppcms) to support MSVC, including building static and dynamic libraries with CMake. And I get all the time absolutely weird issues: I had CMake build issues because Windows programming lacks namin...