Click here to Skip to main content
15,914,165 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: escape SQL statment Pin
Carlos Antollini21-Sep-01 10:03
Carlos Antollini21-Sep-01 10:03 
GeneralRe: escape SQL statment Pin
21-Sep-01 10:31
suss21-Sep-01 10:31 
GeneralRe: escape SQL statment Pin
Carlos Antollini21-Sep-01 10:46
Carlos Antollini21-Sep-01 10:46 
Questionftp transfert ? Pin
youssef21-Sep-01 8:22
youssef21-Sep-01 8:22 
AnswerRe: ftp transfert ? Pin
Joaquín M López Muñoz21-Sep-01 8:56
Joaquín M López Muñoz21-Sep-01 8:56 
Questionhiding other apps splash screens? Pin
Joan M21-Sep-01 7:58
professionalJoan M21-Sep-01 7:58 
AnswerRe: hiding other apps splash screens? Pin
Joaquín M López Muñoz21-Sep-01 9:53
Joaquín M López Muñoz21-Sep-01 9:53 
GeneralString resources & MAKEINTRESOURCE Pin
Chen Venkataraman21-Sep-01 7:41
Chen Venkataraman21-Sep-01 7:41 
I'm trying to understand how the string resources ids are converted into the actual strings as i ran into MAKEINTRESOURCE. A number of Win32 API calls accept string resource id wrapped in the above macro. Does anybody know what exactly does MAKEINTRESOURCE accomplish?

Here's how it is defined in WinUser.h

#define MAKEINTRESOURCEA(i) (LPSTR)((DWORD)((WORD)(i)))

Also, while looking at AfxLoadString, i came across the following code in DLLINIT.cpp

<br />
// AfxLoadString must not only check for the appropriate string segment<br />
//   in the resource file, but also that the string is non-zero<br />
int AFXAPI AfxLoadString(UINT nID, LPTSTR lpszBuf, UINT nMaxBuf)<br />
{<br />
	ASSERT(AfxIsValidAddress(lpszBuf, nMaxBuf*sizeof(TCHAR)));<br />
<br />
	LPCTSTR lpszName = MAKEINTRESOURCE((nID>>4)+1);<br />
	HINSTANCE hInst;<br />
	int nLen;<br />
<br />
	// first check the main module state<br />
	AFX_MODULE_STATE* pModuleState = AfxGetModuleState();<br />
	if (!pModuleState->m_bSystem)<br />
	{<br />
		hInst = AfxGetResourceHandle();<br />
		if (::FindResource(hInst, lpszName, RT_STRING) != NULL &&<br />
			(nLen = ::LoadString(hInst, nID, lpszBuf, nMaxBuf)) != 0)<br />
		{<br />
			// found a non-zero string in app<br />
			return nLen;<br />
		}<br />
	}<br />
<br />
// rest deleted<br />


What is going on here?? The string resource id is right-shifted 4 bits & added 1 & cast as LPSTR and finally assigned to a LPCTSTR variable - this is then used by ::FindResource & ::LoadString to fetch the actual string?? I'm beginning to lose it here!! Confused | :confused: Confused | :confused:

Anybody has ideas??

Chen Venkataraman
GeneralRe: String resources & MAKEINTRESOURCE Pin
Tomasz Sowinski21-Sep-01 7:56
Tomasz Sowinski21-Sep-01 7:56 
GeneralRe: String resources & MAKEINTRESOURCE Pin
The_Server21-Sep-01 12:21
The_Server21-Sep-01 12:21 
GeneralRe: String resources & MAKEINTRESOURCE Pin
Michael Dunn21-Sep-01 14:06
sitebuilderMichael Dunn21-Sep-01 14:06 
GeneralPlotting algebraic expressions Pin
21-Sep-01 6:18
suss21-Sep-01 6:18 
Questionhow could i reallocate an array? Pin
Gérald Mercet21-Sep-01 5:18
Gérald Mercet21-Sep-01 5:18 
AnswerRe: how could i reallocate an array? Pin
Joaquín M López Muñoz21-Sep-01 5:58
Joaquín M López Muñoz21-Sep-01 5:58 
GeneralRe: how could i reallocate an array? Pin
Nemanja Trifunovic21-Sep-01 6:10
Nemanja Trifunovic21-Sep-01 6:10 
GeneralScrollbar position in list control Pin
21-Sep-01 5:00
suss21-Sep-01 5:00 
GeneralRe: Scrollbar position in list control Pin
Michael Dunn21-Sep-01 14:16
sitebuilderMichael Dunn21-Sep-01 14:16 
GeneralCreating OCX with VC++ Pin
José Carlos21-Sep-01 3:52
José Carlos21-Sep-01 3:52 
GeneralRe: Creating OCX with VC++ Pin
Michael P Butler21-Sep-01 4:22
Michael P Butler21-Sep-01 4:22 
GeneralActiveXControl Pin
Remi Morin21-Sep-01 3:42
Remi Morin21-Sep-01 3:42 
GeneralRefreshing Client Area Pin
21-Sep-01 3:35
suss21-Sep-01 3:35 
GeneralRe: Refreshing Client Area Pin
Remi Morin21-Sep-01 3:41
Remi Morin21-Sep-01 3:41 
GeneralButtons......EditBox Pin
Ahmad9921-Sep-01 3:33
Ahmad9921-Sep-01 3:33 
GeneralRe: Buttons......EditBox Pin
21-Sep-01 6:18
suss21-Sep-01 6:18 
GeneralRe: Buttons......EditBox....Thanks and Need MoreHelp Pin
Ahmad9922-Sep-01 0:04
Ahmad9922-Sep-01 0:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.