Click here to Skip to main content
15,902,842 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to threshold an image? Pin
cmk21-Jan-04 9:51
cmk21-Jan-04 9:51 
AnswerRe: How to threshold an image? Pin
uus9921-Jan-04 16:30
uus9921-Jan-04 16:30 
AnswerRe: How to threshold an image? Pin
Ryan Binns21-Jan-04 17:28
Ryan Binns21-Jan-04 17:28 
Questionthe system protect in 2k and xp ?? Pin
Anonymous21-Jan-04 4:47
Anonymous21-Jan-04 4:47 
AnswerRe: the system protect in 2k and xp ?? Pin
Matt Newman21-Jan-04 5:40
Matt Newman21-Jan-04 5:40 
AnswerRe: the system protect in 2k and xp ?? Pin
Antti Keskinen21-Jan-04 5:42
Antti Keskinen21-Jan-04 5:42 
GeneralBest way to display a text file as a resource Pin
doctorpi21-Jan-04 4:06
doctorpi21-Jan-04 4:06 
GeneralRe: Best way to display a text file as a resource Pin
Roger Allen21-Jan-04 4:42
Roger Allen21-Jan-04 4:42 
Put a line like this in your projects .rc2 file:

RESOURCE_NAME TEXTFILE "res\\MyTextFile.txt"


Then to extract it in code:

CString target;
LoadResource(&target, "RESOURCE_NAME");

bool LoadResource(CString *script, const char* name)
{
	// load the resource
	bool bOK = false;
	HRSRC hFRes = ::FindResource(AfxGetResourceHandle(), name, "TEXTFILE");
	if (hFRes != NULL)
	{
		HANDLE hRes = ::LoadResource(AfxGetResourceHandle(), hFRes);
		if (hRes != INVALID_HANDLE_VALUE)
		{
			// we loaded it, now get the text from it
			char *lpRes = (char*)::LockResource(hRes);
			DWORD size = SizeofResource(AfxGetResourceHandle(), hFRes);
			// we need to use the size of the resource like this because the lpRes pointer
			// can have many text files as 1 string, we need to extract
			// the text for our file only, by knowing how many bytes to copy into
			// to the target string
			CString format;
			format.Format("%%.%1ds", size);
			script->Format(format, lpRes);
			::UnlockResource(hRes);
			::FreeResource(hRes);
			bOK = true;
		}
	}
	return bOK;
}



Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
Generalcustom class wizard Pin
red2k421-Jan-04 3:50
sussred2k421-Jan-04 3:50 
GeneralRe: custom class wizard Pin
Antti Keskinen21-Jan-04 5:49
Antti Keskinen21-Jan-04 5:49 
GeneralNon-blocking Socket getting block on WSASend Pin
Member 73613721-Jan-04 3:20
Member 73613721-Jan-04 3:20 
GeneralRe: Non-blocking Socket getting block on WSASend Pin
valikac21-Jan-04 11:28
valikac21-Jan-04 11:28 
GeneralRe: Non-blocking Socket getting block on WSASend Pin
Anonymous22-Jan-04 2:19
Anonymous22-Jan-04 2:19 
Generalcreating Access ODBC Data Source at runtime Pin
bmvbab21-Jan-04 3:11
bmvbab21-Jan-04 3:11 
GeneralRe: creating Access ODBC Data Source at runtime Pin
David Crow21-Jan-04 4:53
David Crow21-Jan-04 4:53 
Questionhow to extract a single bitmap from .avi file? Pin
andreas.schaerer21-Jan-04 3:10
andreas.schaerer21-Jan-04 3:10 
AnswerRe: how to extract a single bitmap from .avi file? Pin
Ted Ferenc21-Jan-04 3:19
Ted Ferenc21-Jan-04 3:19 
GeneralRe: how to extract a single bitmap from .avi file? Pin
andreas.schaerer21-Jan-04 3:30
andreas.schaerer21-Jan-04 3:30 
GeneralRe: how to extract a single bitmap from .avi file? Pin
Ted Ferenc21-Jan-04 3:48
Ted Ferenc21-Jan-04 3:48 
GeneralRe: how to extract a single bitmap from .avi file? Pin
andreas.schaerer21-Jan-04 9:48
andreas.schaerer21-Jan-04 9:48 
GeneralRe: how to extract a single bitmap from .avi file? Pin
Ted Ferenc21-Jan-04 21:38
Ted Ferenc21-Jan-04 21:38 
GeneralRe: how to extract a single bitmap from .avi file? Pin
andreas.schaerer1-Feb-04 8:02
andreas.schaerer1-Feb-04 8:02 
GeneralRe: how to extract a single bitmap from .avi file? Pin
Ted Ferenc1-Feb-04 8:53
Ted Ferenc1-Feb-04 8:53 
GeneralUSB Port sample Pin
DT_SE21-Jan-04 3:06
DT_SE21-Jan-04 3:06 
GeneralRe: USB Port sample Pin
Antti Keskinen21-Jan-04 6:24
Antti Keskinen21-Jan-04 6:24 

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.