Click here to Skip to main content
15,889,034 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: App Icon not showing correctly on desktop Pin
$motty24-Aug-06 20:58
$motty24-Aug-06 20:58 
GeneralRe: App Icon not showing correctly on desktop Pin
Waldermort24-Aug-06 22:51
Waldermort24-Aug-06 22:51 
GeneralRe: App Icon not showing correctly on desktop [modified] Pin
$motty25-Aug-06 4:53
$motty25-Aug-06 4:53 
Questionsend message to Yahoo user Pin
Silly Boy24-Aug-06 7:15
Silly Boy24-Aug-06 7:15 
QuestionRe: send message to Yahoo user Pin
David Crow24-Aug-06 7:37
David Crow24-Aug-06 7:37 
AnswerRe: send message to Yahoo user Pin
jk chan24-Aug-06 14:27
jk chan24-Aug-06 14:27 
AnswerRe: send message to Yahoo user Pin
ThatsAlok24-Aug-06 18:08
ThatsAlok24-Aug-06 18:08 
QuestionChanging bitmaps using UpdateResource Pin
Kharfax24-Aug-06 7:09
Kharfax24-Aug-06 7:09 
Hi people, im using Update Resource to change a Bitmap in a DLL.

The bitmap is beign changed, but the new added bitmap hasn't a valid format.

I found this at expert exchange
char* buf = (char*)HeapAlloc (GetProcessHeap(), 0, dwFileSize + 2);
memcpy (buf, &dwFileSize, sizeof (dwFileSize));
memcpy (buf + 4, lpBuffer + 2, dwFileSize - 2);

This guy said that the resource BMP dont start with BM, instead the first 4 bytes are the lenght of the resource.
But a working BMP in the DLL begins with BM.

I tried without that code and the newly added BMP has an invalid format anyway.

Any suggestion??

Thanks a lot people Big Grin | :-D




HANDLE hFile;<br />
	DWORD dwFileSize, dwBytesRead;<br />
	LPBYTE lpBuffer;<br />
<br />
	hFile = CreateFile("test.bmp", GENERIC_READ, <br />
                   0,<br />
                   NULL,<br />
                   OPEN_EXISTING,<br />
                   FILE_ATTRIBUTE_NORMAL,<br />
                   NULL);<br />
<br />
	if (INVALID_HANDLE_VALUE != hFile)<br />
	{<br />
		dwFileSize = GetFileSize(hFile, NULL);<br />
<br />
		lpBuffer = new BYTE[dwFileSize];<br />
<br />
		if (ReadFile(hFile, lpBuffer, dwFileSize, &dwBytesRead, NULL) != FALSE)<br />
	  {<br />
<br />
<br />
                  /// I found this at experts exchange<br />
		  char* buf = (char*)HeapAlloc (GetProcessHeap(), 0, dwFileSize + 2);<br />
		  memcpy (buf, &dwFileSize, sizeof (dwFileSize));<br />
		  memcpy (buf + 4, lpBuffer + 2, dwFileSize - 2);<br />
<br />
<br />
		  <br />
			if( UpdateResource( targetModule,<br />
								RT_BITMAP,<br />
								MAKEINTRESOURCE(1002),<br />
								MAKELANGID(LANG_SPANISH,SUBLANG_SPANISH_ARGENTINA),<br />
								(LPVOID)buf,<br />
								 sizeof(buf))) {<br />
<br />
									MessageBox("Update OK", NULL, MB_OK);<br />
	<br />
								}<br />
			else {<br />
				MessageBox("Error in update", NULL, MB_OK);<br />
			}<br />
<br />
			//Cierro edicion de recursos<br />
			if(EndUpdateResource(targetModule, FALSE)) <br />
				MessageBox("Res changed", "ERROR", MB_OK);<br />
			else<br />
				MessageBox("Error updating res", "ERROR", MB_OK);<br />
        <br />
		    <br />
	  }<br />
<br />
    delete [] lpBuffer;        <br />
    <br />
    CloseHandle(hFile);<br />
}

AnswerRe: Changing bitmaps using UpdateResource Pin
David Crow24-Aug-06 7:36
David Crow24-Aug-06 7:36 
GeneralRe: Changing bitmaps using UpdateResource Pin
Kharfax24-Aug-06 7:46
Kharfax24-Aug-06 7:46 
GeneralRe: Changing bitmaps using UpdateResource Pin
$motty24-Aug-06 8:18
$motty24-Aug-06 8:18 
GeneralRe: Changing bitmaps using UpdateResource Pin
Kharfax24-Aug-06 8:27
Kharfax24-Aug-06 8:27 
GeneralRe: Changing bitmaps using UpdateResource Pin
jk chan24-Aug-06 14:42
jk chan24-Aug-06 14:42 
GeneralRe: Changing bitmaps using UpdateResource Pin
Kharfax25-Aug-06 2:21
Kharfax25-Aug-06 2:21 
AnswerProblem solved Pin
Kharfax25-Aug-06 4:40
Kharfax25-Aug-06 4:40 
Questionmemcpy and memset on a structure which has a class as it's member Pin
Diagon Alley24-Aug-06 5:09
Diagon Alley24-Aug-06 5:09 
AnswerRe: memcpy and memset on a structure which has a class as it's member Pin
toxcct24-Aug-06 6:14
toxcct24-Aug-06 6:14 
AnswerRe: memcpy and memset on a structure which has a class as it's member Pin
cmk24-Aug-06 7:08
cmk24-Aug-06 7:08 
AnswerRe: memcpy and memset on a structure which has a class as it's member Pin
Zac Howland25-Aug-06 9:19
Zac Howland25-Aug-06 9:19 
AnswerThanks Guys! Pin
Diagon Alley29-Aug-06 18:58
Diagon Alley29-Aug-06 18:58 
QuestionChanging tray icon tooltip message Pin
samaruf24-Aug-06 5:01
samaruf24-Aug-06 5:01 
AnswerRe: Changing tray icon tooltip message Pin
Waldermort24-Aug-06 7:55
Waldermort24-Aug-06 7:55 
GeneralRe: Changing tray icon tooltip message Pin
ThatsAlok24-Aug-06 18:10
ThatsAlok24-Aug-06 18:10 
GeneralRe: Changing tray icon tooltip message Pin
Waldermort24-Aug-06 22:54
Waldermort24-Aug-06 22:54 
QuestionConfussion with Assigning an applications's process priority [modified] Pin
kitty524-Aug-06 5:01
kitty524-Aug-06 5:01 

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.