winapi,visual-studio-2008,win32gui , How can I manually add a resource to a Win32 resource file


How can I manually add a resource to a Win32 resource file

Question:

Tag: winapi,visual-studio-2008,win32gui

Visual Studio Win32 projects have a resource file. One can add and configure controls using a GUI interface. However I have a need to enter about 80 check boxes which is very tedious using the GUI. I can open the resource file in a text editor, but if I try and add a new control, Visual Studio cannot understand it. I used to be able to do that in the old WATCOM C++ IDE/compiler.

Clearly VS is doing something else that just making the resource file.

Is there any way to create and add resources (lie controls) by manually editing the rc file?


Answer:
  1. Write the .rc file.
  2. Use the resource compiler, rc.exe to compile the .rc file to a compiled resource, .res.
  3. Pass the compiled resource to the linker.

Related:


Count digits in file using WinApi functions


c++,winapi,createfile
I need to count digits in file using CreateFile and ReadFile methods from <Windows.h>. Here's what I have: int CountDigitsInFile(PCTSTR path) { HANDLE hFile = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { _tprintf_s(TEXT("Open File Error")); return NULL; } TCHAR data[100]; DWORD dwRead; DWORD dwFileSize =...

std::vector content change when read inside the main()


c++,string,winapi,vector
I was writing this function to search a file inside the computer but i encountered a problem: When I read the files that have been found during the search(using the for cycle inside the main() ) the directory are broken. With some debugging I saw that when pushed inside the...

Explain what problems could have this function (if any)


.net,vb.net,winapi,pinvoke,getlasterror
SCENARIO When P/Invoking, I thinked it could be a great idea to simplify/reduct tons of code by designing a generic function that calls the function, then it checks for the GetLastWin32Error I'm using this code: ''' <summary> ''' Invokes the specified encapsulated function, trying to provide a higher safety level...

Access std::map from different threads


c++,windows,winapi
I have read that std::map is not thread safe. So if I am accessing (read/write) the std::map from different threads, should I simply wrap the relevant code in a critical section? Note: I am using Visual C++ 2010....

Populating a List Control with the sorted contents of an `std::multimap`?


c++,winapi,stl,mfc,clistctrl
As a follow-up to this question, I need a way to access my data by index. But the data needs to be sorted by timestamp, contain a filepath as a value, and be displayed in real-time as new elements are discovered. Considering that multiple files/folders could potentially contain an identical...

Win32 Message Pump and std::thread Used to Create OpenGL Context and Render


multithreading,winapi,opengl,c++11
If I have a function that does the following: bool foo::init() { [Code that creates window] std::thread run(std::bind(&foo::run, this)); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } } Where run is defined as: void foo::run() { [Code that creates initial opengl context] [Code that recreates window based on new...

Confusion about CTRL_SHUTDOWN_EVENT handling in DLLs and WM_QUERYENDSESSION


c,winapi,console,shutdown
My UI is in a DLL. Right now, both the DLL and the EXE that uses it are compiled as console programs so I can use stdout and stderr for debugging and error reporting during development. One of the things is that I have an uninit() function that makes sure...

Is a StatusBar created in simple mode by default?


c,winapi
When a StatusBar is first created, for example: HWND hStatusBar = CreateWindowEx(0, STATUSCLASSNAME, "", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, 0, GetModuleHandle(NULL), NULL); Is it created in simple mode or in multiple-part mode? or maybe this is not guaranteed and it is better to set the mode I...

Implementing callback function for dialog-based application


c++,c,visual-studio,user-interface,winapi
I was reading a very old tutorial on how to create a dialog-based GUI application in Visual C++ (source - in portuguese). Based on my weak knowledge on WinAPI programming I decided to modify the proposed code mainly to achieve two things: 1) Consistency with Unicode programming standard (using wWinMain...

Get list of process


delphi,winapi
I need to get the list of process with their PID. I know how to get the PID by its handle and viceversa, but the problem is that I'm not the one who create the process, so I don't have the handle nor the PID. I didn't find exactly information...

MessageBox won't work when handling WM_DESTROY event from DialogBox


c,user-interface,winapi
While elaborating an answer for another question (by myself), I've come up with the idea of using a MessageBox to report the result of my dialog box. It is a WinAPI modal dialog box created with the DialogBox() function. However, I noticed that handling WM_DESTROY in the dialog's procedure function...

Obtain thread handles/id of a specific process


c++,multithreading,winapi
I have a multi-threaded embedded architecture that contains 6 application specific processes which are executed when the initialization process is executed. Likewise, each have their own number of threads that are running. What i want to do is suspend the running threads of 1 particular process based on whether the...

User process can't see global shared memory created by service


c++,windows,security,winapi,memory-mapped-files
I have a Windows service (running in the system process) and a desktop application that need to share a configuration structure. The data originates in the app, but the user process doesn't have permission to create a global memory object so I create it when the service starts using CreateFileMapping()...

MoveFileEx() File removal on reboot


c++,windows,winapi
Currently I can remove a directory on reboot. Im currently doing this by using the MoveFileEx function along with passing the MOVEFILE_DELAY_UNTIL_REBOOTconstant. My question is if I have the following: Directory 1 and inside I have Directory 2... Directory 2 is unistalled which means the directory needs to be removed...

Restarting a process from another process


c++,winapi
I have two processes: ProcessA and ProcessB. When i launch my application, i call ProcessA which uses CreateProcess() to launch ProcessB. ProcessA is killed by ProcessB when my application receives command A. Likewise, ProcessB should relaunch ProcessA when it receives command B. Where i am stuck on is on the...

ICallFactory with 32-bit and 64-bit type libraries side by side


windows,winapi,com,registry,typelib
I have a in-proc COM server for which I want to build 32-bit and 64-bit versions. I can do this with no problem. However, I am encountering some issues when both versions are registered. I am not using ATL. In my DllRegisterServer function, I am using RegisterTypeLibForUser. I am acquiring...

How to handle an event message while using chrome embedded framework (CEF)?


c++,winapi,visual-c++,chromium-embedded
I'm using Chromium Embedded Framework(CEF) to develop a windows desktop application(using C++/Win32, No MFC). I have used the sample "cefsimple" project and extended on it till now. I have added "Handlers" for keyboard events etc. Everything works fine till now, I can get the handle of the browser window and...

Does LoadLibrary return NULL or an error code < 32 on failure?


winapi
The MSDN documentation states If the function succeeds, the return value is a handle to the module. If the function fails, the return value is NULL. To get extended error information, call GetLastError. while Microsoft support has a list of return values less than 32 that indicate an error The...

Read lines from file async using WINAPI ReadFile


c++,multithreading,winapi,createfile,overlapped-io
I need to read several lines from file simultaneously, i.e. asynchronously. Lines in file are of the same size. For instance, I need to read the second and the fourth lines of file to separate variables or to an array. I'm more used to c#'s async/await and all these OVERLAPPED...

Passing HWND through to a method and storing in a class


c++,winapi
I am calling the following: // hMainWindow is a correctly functioning window handle app.GetMainWindowInfo().SetHndToWindow( hMainWindow ); Here are my classes: class App : public BaseClass { public: WindowInfo& GetMainWindowInfo(); void SetMainWindowInfo( unique_ptr<WindowInfo> windowInfo ); private: WindowInfo mainWindowInfo; }; class WindowInfo { public: HWND& GetHndToWindow() const; //void SetHndToWindow( HWND hndToWindow );...

How can I send data between 2 applications using SendMessage?


delphi,winapi
I have 2 applications- Manager with this code: procedure TForm1.CopyData(var Msg: TWMCopyData); var sMsg: String; begin if IsIconic(Application.Handle) then Application.Restore; sMsg := PWideChar(Msg.CopyDataStruct.lpData); Caption := Caption+'#'+sMsg; Msg.Result := 123; end; procedure TForm1.Button1Click(Sender: TObject); const WM_MY_MESSAGE = WM_USER + 1; var h: HWND; begin Caption := 'X'; h := FindWindow('TForm1', 'Client');...

Get all supported FPS values of a camera in Microsoft Media Foundation


c++,windows,winapi,ms-media-foundation
I want to get a list of all FPS values that my webcam supports. In How to Set the Video Capture Frame Rate msdn article it says that I can query the system for maximum and minimum supported FPS of a particular camera. It also says: The device might support...

Why/how does winapi reverse the order of messages?


c++,multithreading,winapi
Consider the following code: CCritialSection listLock; std::list<CString> messageList; extern MyApp theApp; // public inheritance from CWinApp const int aMessageNumber = WM_APP + 123; void MyApp::EnqueueMessageForUIThread( const CString message ) { CSingleLock lock( &listLock, TRUE ); messageList.push_back( message ); theApp.m_pMainWnd->PostMessage( aMessageNumber ); } void MyApp:PopupMessageFromNonUIThread( void) { // This function is...

More convenient way to work with strings in winapi calls


string,winapi,rust
I'm looking for more convenient way to work with std::String in winapi calls in Rust. Using rust v 0.12.0-nigtly with winapi 0.1.22 and user32-sys 0.1.1 Now I'm using something like this: use winapi; use user32; pub fn get_window_title(handle: i32) -> String { let mut v: Vec<u16> = Vec::new(); v.reserve(255); let...

How do I call LocalFree()?


c,winapi
I have this piece of code HLOCAL localHandle; char *lpText; localHandle = LocalAlloc(LMEM_MOVEABLE, 40); if(localHandle) { lpText = (char*)LocalLock(localHandle); //Call LocalFree(localHandle) or LocalFree(lpText) ???? } Should I call LocalFree(localHandle); or LocalFree(lpText); ?...

How to execute a file with a different extension's associated application?


delphi,winapi,shellexecute,file-association
In my application, I would like to be able to execute a file with an arbitrary name and extension using the program associated with a different extension. For example, say I have a file called file.dat, but I wanted to open it with Notepad, as if it was named file.txt...

call Win32 API in flex to set Window Display Affinity


winapi,flex,air
I have created a Flex Desktop Application with Adobe Air. I need to protect the application from being captured. By changing the window display affinity of the application, the application can be protected from being captured. How to use win API in flex? Is there any other way to protect...

New window opening with parent window's controls


c++,winapi
Sorry for english slaughter but i can't find anything about that. I'm trying to open an empty window in c++ with winapi but new window opening with parent window's controls like a clone. case VBTN: { vsa1 = CreateWindowEx(NULL, L"Window Class", L"Test", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 350,...

If statement not working in vb6


winapi,vb6
I want to make a program which could close a window with the title "Personalization" in vb6. The problem is that the if statement is not working.Here's my code(it only finds a window named "Personalization" without closing it): Option Explicit Private Sub Command1_Click() Timer1.Enabled = Not Timer1.Enabled End Sub Private...

how to change Text to Speech voice and how to insert characters into char array


c++,arrays,windows,winapi,text-to-speech
I need to change the voie of the Text To Speech engine. when a menu is selected ID_SPEAK_PLAY I get the text of an edit box and simply read it. my situation can be solved in two ways : insert the XML code at the begining of ptrData without using...

Hide Window from taskbar without using WS_EX_TOOLWINDOW


c,winapi
I have a main Window and an About Window, The About Window is opened from the main Window, but the problem is that the About Window is shown in the taskbar! I have found that in order to hide a Window from the taskbar, I can use the WS_EX_TOOLWINDOW style,...

I need to dynamically set the date in a where statement to only pull results from a table to occur in County's fiscal year


sql,sql-server-2008,date,datetime,visual-studio-2008
Here is my current code: SELECT nature, inci_id, calltime, agency, gp FROM inmain AS inmain WHERE (calltime >= CONVERT(DATETIME, '2013-07-01 00:00:00', 102)) AND (calltime <= CONVERT(DATETIME, '2014-06-30 23:59:59', 102)) ORDER BY nature, calltime I need this to pull data at the end of every fiscal year without going in and...

Same version number for different Windows versions


c,winapi
In this page, there is something like this: Windows Server 2008 6.0 Windows Vista 6.0 GetVersionEx() returns the version number (i.e. 6.0), but as you can see, this number can map to two different Windows versions! So is there's a way to know exactly what Windows version I have?...

Issue finding exe path of all windows in python


python,windows,winapi
I am using the code below to determine the foreground window and find the path for the .exe file that created it. hwnd = win32gui.GetForegroundWindow() _, pid = win32process.GetWindowThreadProcessId(hwnd) hndl = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, 0, pid) path = win32process.GetModuleFileNameEx(hndl, 0) print path This workd for windows such as Google Chrome,...

Accessing GetConsoleHistoryInfo() from managed code


c#,winapi,console-application,dllimport,managed
I've got a vaguely Java background and just installed Visual Studio Community 2015. Playing about with it so have a console app up and running and wanted to use above function after attaching to a different Console. Trouble is I have no idea about the appropriate declaration for this function...

How to create a submenu for a popup menu?


c,winapi
When I want to create a popup menu, I would use the CreatePopupMenu() function. But what if one of the popup menu items needs to have a submenu, should I also use CreatePopupMenu() to create the submenu, or should I use CreateMenu()?...

MASM console window creation troubles (maybe my stack frame??)


winapi,assembly,stack,x86-64,masm
I'm having trouble with the following code snippet. I'm compiling an asm file with a c++ file using visual studio express 2012. I've tried debugging calculating the addresses of the stack pointers and memory locations (still learning assembly obviously), but can't find a fault. (As I'm new it's probably something...

Edit control doesn't generate WM_COMMAND messages


winapi,controls,editcontrol
I have an edit control. In the parent window I'm listening a WM_COMMAND message. But my control doesn't send it on change. Moreover, when I'm watching messages with Spy I can see only different keyboard messages on the edit control itself and the only message in the main parent window...

heap error after changing from new allocation to smartpointer


c++,winapi
extern "C" int __stdcall calcA( LPCSTR SerialNumber, double Diameter, int Design, int FoilSpacing, double RotorSpeed, double Altitude, double SupplyAirInletTemperature, double SupplyAirInletMoistureContent, double ExhaustAirInletTemperature, double ExhaustAirInletMoistureContent, double SupplyAirOutletFlow, double ExhaustAirInletFlow, double PressureDifference, bool PurgingSector, double* PowerTotal, double* PowerSensibel, double* TemperatureEfficiency, double* HumidityEfficiency, double* SupplyAirOutletTemperature, double*...

How can a dialog become responsive while waiting for a call to DoModal() to return?


winapi,com,mfc,modal-dialog
A button on a dialog causes a child dialog to be created, and displayed modally. e.g: void ParentDialog::OnButton() { ChildDialog dlg; int ret = dlg.DoModal(); } The parent dialog is initially unresponsive as expected. But, the child dialog also makes COM calls to a server module, which causes the server...

C++ and WinApi - usage of GetWindowText() to get parameters for C++ code


c++,winapi,file-io
I have coded some C++ console program which converts one filetype to another. I need to turn the console application into a window one. I have never made window applications. I have chosen WinApi, because I don't have much time and don't want to change IDE (DEV C++ 5.10), compiler/linker...

GetWindowsDirectory() API returns wrong (vba\vb6)


vba,winapi,vb6
on my Windows-Terminal user, I'm trying to have two application point to the same Windows directory, one written in VBA one in VB6. When calling the GetWindowsDirectory() API from VB6 it returns the correct path C:\documents and settings\%user%\Windows When calling it from VBA macro, it returns C:\Windows Notice that same...

How To Get Window handles In Mozilla Firefox


winapi,mfc,ui-automation
How to get handles of all the child windows in Mozilla firefox. Spy++ is showing only one class and window caption for all the windows. I tried using GetWindow and FindWindowEx but got nothing. I want to read URL from mozilla firefox.

Generating a self-signed X509Certificate2 certificate with its private key


c#,.net,winapi,pki,x509certificate2
I'm not the most familiar with the unmanaged cryptography library in the Windows API, but alas I am trying to generate a self-signed X509Certificate2 certificate. Here is the complete code: using System; using System.Security; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Security.Cryptography.X509Certificates; namespace Example { [StructLayout(LayoutKind.Sequential)] public struct SystemTime { public short...

How should I read the filename in FILE_NOTIFY_INFORMATION struct


c++,winapi,filesystems,file-monitoring,readdirectorychangesw
I'm trying to monitor file changes but I am not really sure on how to read the filename in the FILE_NOTIFY_INFORMATION struct: HANDLE dwChangeHandles[2]; DWORD dwWaitStatus; wChangeHandles[0] = FindFirstChangeNotification(dirname.c_str(), FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE); if (dwChangeHandles[0] == INVALID_HANDLE_VALUE) printerr(__FILE__,__LINE__,"FindFirstChangeNotification function failed.\n"); ... if ((dwChangeHandles[0] == NULL) || (dwChangeHandles[1] == NULL)) //final validation printerr(__FILE__,__LINE__,"Unexpected...

C++ Windows API DlgDirList sometimes don't return the correct listing


c++,winapi,listbox,directory-listing,file-listing
I have 2 List Box, one always listing directories from a path and other listing the files from the selected directory. The first time i select a directory, the files are shown properly, but if i select another directory, it lists nothing. That's my current main.cpp, where all GUI stuff...

winapi: from HDC to an HBITMAP


c++,winapi,bitmap,gdi
I would like to do something which I believe is fairly simple but since I am new to the winapi I am finding a lot of problems. Basically I have an HDC (which I am BitBlitting from a loaded Bitmap) and I am drawing a rectangle on it. Then I...

How do I declare OutputDebugStringA without windows.h macros?


c++,winapi
You know how Python has from urllib import *, but also offers from urllib import request, so you can just import that one symbol? Unfortunately C/C++ don't offer that but that's what I would like to do here: from windows.h import OutputDebugStringA, because all I need is that one function....

Is it valid to mutilayered a critical section?


c++,winapi,critical-section
For example, is this valid? CRITICAL_SECTION cs_A; CRITICAL_SECTION cs_b; ::InitializeCriticalSection( &cs_A ); ::InitializeCriticalSection( &cs_B ); ::EnterCriticalSection( &cs_A ); // First level /* do some stuff with A */ ::EnterCriticalSection( &cs_B ); // Second level /* do some stuff with A and B */ ::LeaveCriticalSection( &cs_B ); // Second level /*...

Can a dialog intercept drag'n'drop messages passed to its controls?


winapi,mfc,drag-and-drop
If a dialog registers some of its controls as drop-targets, will drag'n'drop messages intended for those controls pass through the dialog's message processing in a way that the dialog can register a message handler to be notified/intercept those messages? In a similar fashion to this question, I want to catch...