Using SetWindowPos with multiple monitors

System Displays disposition and VirtualScreen In a Windows System, the Primary Screen (programming perspective) is the Display device which has its upper left corner position set at Point(0,0). This implies that the Displays positioned on the left of the Primary Screen, will have negative X coordinates (the Y coordinate could be negative if the Display … Read more

How to provide user name and password when connecting to a network share

I liked Mark Brackett’s answer so much that I did my own quick implementation. Here it is if anyone else needs it in a hurry: public class NetworkConnection : IDisposable { string _networkName; public NetworkConnection(string networkName, NetworkCredential credentials) { _networkName = networkName; var netResource = new NetResource() { Scope = ResourceScope.GlobalNetwork, ResourceType = ResourceType.Disk, DisplayType … Read more

GetDlgCtrlID for top-level window with menu bar – return value

It is not inaccurate. You create a top-level window with CreateWindowEx(). Which looks like this: HWND WINAPI CreateWindowEx( _In_ DWORD dwExStyle, _In_opt_ LPCTSTR lpClassName, _In_opt_ LPCTSTR lpWindowName, _In_ DWORD dwStyle, _In_ int x, _In_ int y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam ); … Read more

How can I properly install Win32::GuiTest?

Update: Given that you get Error: No valid repositories, clearly you have somehow borked your ppm configuration. Add some repositories. Original answer: Use ppm to install the module: ppm install Win32::GuiTest C:\Home> ppm install Win32::GuiTest Downloading ActiveState Package Repository packlist…done Updating ActiveState Package Repository database…done Downloading bribes packlist…done Updating bribes database…done Downloading trouchelle packlist…done Updating … Read more

How to convert UCHAR Virtual-Key Codes into std::string [duplicate]

Three problems in getKeyPressedString: 1) You´re not deleting lpszName again. Either make a delete lpszName; before returning, or use a static buffer in the first place. 2) keyString = *lpszName; only assigns the first character, not the whole string. Remove *. 3) GetKeyNameText can fail. Check the return value, and GetLastError too. (side note: ERROR_INSUFFICIENT_BUFFER … Read more