Click here to Skip to main content
15,898,861 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: foreach....recursively - assistance with C++ code wnated Pin
Salvatore Terress8-May-24 17:09
Salvatore Terress8-May-24 17:09 
GeneralRe: foreach....recursively - assistance with C++ code wnated Pin
Salvatore Terress10-May-24 13:23
Salvatore Terress10-May-24 13:23 
Questionvoluntarily REMOVED Which way is correct ? Pin
Salvatore Terress6-May-24 10:19
Salvatore Terress6-May-24 10:19 
AnswerRe: Which way is correct ? Pin
Richard MacCutchan7-May-24 0:29
mveRichard MacCutchan7-May-24 0:29 
AnswerRe: voluntarily REMOVED Which way is correct ? Pin
Richard MacCutchan9-May-24 5:59
mveRichard MacCutchan9-May-24 5:59 
QuestionPassing "parent" error Pin
Salvatore Terress4-May-24 6:51
Salvatore Terress4-May-24 6:51 
AnswerRe: Passing "parent" error Pin
Richard MacCutchan5-May-24 2:45
mveRichard MacCutchan5-May-24 2:45 
Questionchange exe icon not work with multiple stage icon file. Pin
Le@rner1-May-24 2:26
Le@rner1-May-24 2:26 
hi all,

i am change my exe icon its working fine with icon which have single stage icon.

but if i select a icon file that have multiple size stages in icon file, icon not reflect on exe.

HANDLE handle = BeginUpdateResource(exe_file, FALSE);

   char *buffer;    // buffer to store raw icon data
   long buffersize; // length of buffer
   int hFile;       // file handle
       
   hFile = open(ico_file, O_RDONLY | O_BINARY);
   if (hFile == -1)
      return; // if file doesn't exist, can't be opened etc. 
       
   // calculate buffer length and load file into buffer
   buffersize = filelength(hFile);
   buffer = (char *)malloc(buffersize);
   read(hFile, buffer, buffersize);
   close(hFile);

   int icon_id=1;


	 UpdateResource(
	  handle,  // Handle to executable
	  RT_ICON, // Resource type - icon
	  MAKEINTRESOURCE(icon_id), // Make the id 1
	  
	  MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),

	  (buffer+22), 
	  // skip the first 22 bytes because this is the 
	  // icon header&directory entry (if the file 
	  // contains multiple images the directory entries
	  // will be larger than 22 bytes
	  buffersize-22  // length of buffer
	 );

  

	/////////////////////
   // Again, we use this structure for educational purposes.
   // The icon header and directory entries can be read from 
   // the file.
   GROUPICON grData;

   icon_id=1;

   // This is the header
   grData.Reserved1 = 0;     // reserved, must be 0
   grData.ResourceType = 1;  // type is 1 for icons
   grData.ImageCount = 1;    // number of icons in structure (1)

   // This is the directory entry
   grData.Width = 32;        // icon width (32)
   grData.Height = 32;       // icon height (32)

   grData.Colors = 0;        // colors (256)
   grData.Reserved2 = 0;     // reserved, must be 0
   grData.Planes = 2;        // color planes
   grData.BitsPerPixel = 32; // bit depth
   
   grData.ImageSize = buffersize - 22; // size of image
   
   grData.ResourceID = icon_id;       // resource ID is 1

   UpdateResource(
      handle,
      RT_GROUP_ICON,
	  
	  MAKEINTRESOURCE(icon_id),
      // MAINICON contains information about the
      // application's displayed icon
      
	  MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),

      &grData,
      // Pointer to this structure
      sizeof(GROUPICON)
     );

   delete buffer; // free memory
         

   // Perform the update, don't discard changes
  // Write changes then close it. 
	if (!EndUpdateResource(handle, FALSE)) 
	{ 
	
		return ;
	}


please help me where i am doing mistake.

thanks in advance.
AnswerRe: change exe icon not work with multiple stage icon file. Pin
Victor Nijegorodov1-May-24 4:21
Victor Nijegorodov1-May-24 4:21 
GeneralRe: change exe icon not work with multiple stage icon file. Pin
jschell1-May-24 13:09
jschell1-May-24 13:09 
AnswerRe: change exe icon not work with multiple stage icon file. Pin
CPallini2-May-24 4:07
mveCPallini2-May-24 4:07 
GeneralRe: change exe icon not work with multiple stage icon file. Pin
Dave Kreskowiak2-May-24 4:11
mveDave Kreskowiak2-May-24 4:11 
GeneralRe: change exe icon not work with multiple stage icon file. Pin
CPallini2-May-24 4:14
mveCPallini2-May-24 4:14 
QuestionSOLVED Posting "debug (window ) view ? Pin
Salvatore Terress30-Apr-24 2:51
Salvatore Terress30-Apr-24 2:51 
AnswerRe: Posting "debug (window ) view ? Pin
Maximilien30-Apr-24 2:56
Maximilien30-Apr-24 2:56 
AnswerRe: Posting "debug (window ) view ? Pin
Victor Nijegorodov30-Apr-24 3:40
Victor Nijegorodov30-Apr-24 3:40 
GeneralNavigating thru debug messages using C++ code Pin
Salvatore Terress3-May-24 4:08
Salvatore Terress3-May-24 4:08 
GeneralRe: Navigating thru debug messages using C++ code Pin
Victor Nijegorodov3-May-24 4:13
Victor Nijegorodov3-May-24 4:13 
GeneralRe: Navigating thru debug messages using C++ code Pin
Salvatore Terress3-May-24 6:49
Salvatore Terress3-May-24 6:49 
GeneralRe: Navigating thru debug messages using C++ code Pin
Victor Nijegorodov3-May-24 11:41
Victor Nijegorodov3-May-24 11:41 
GeneralRe: Navigating thru debug messages using C++ code Pin
Richard MacCutchan3-May-24 22:20
mveRichard MacCutchan3-May-24 22:20 
QuestionObjects hierarchy ? Pin
Salvatore Terress29-Apr-24 5:15
Salvatore Terress29-Apr-24 5:15 
AnswerRe: Objects hierarchy ? Pin
Richard MacCutchan29-Apr-24 6:29
mveRichard MacCutchan29-Apr-24 6:29 
QuestionHow to track "nested objects "? Pin
Salvatore Terress18-Apr-24 8:34
Salvatore Terress18-Apr-24 8:34 
AnswerRe: How to track "nested objects "? Pin
Mircea Neacsu18-Apr-24 9:13
Mircea Neacsu18-Apr-24 9:13 

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.