Click here to Skip to main content
16,011,428 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VC++ 6.0, MFC: Two different views attached to same document. Pin
Jun Du11-Sep-06 4:16
Jun Du11-Sep-06 4:16 
GeneralRe: VC++ 6.0, MFC: Two different views attached to same document. Pin
requemao11-Sep-06 6:39
requemao11-Sep-06 6:39 
GeneralRe: VC++ 6.0, MFC: Two different views attached to same document. Pin
Jun Du11-Sep-06 6:59
Jun Du11-Sep-06 6:59 
QuestionGDI+ FontRenderingHint Pin
bob1697210-Sep-06 8:49
bob1697210-Sep-06 8:49 
Questionlparam Pin
Waldermort10-Sep-06 7:56
Waldermort10-Sep-06 7:56 
AnswerRe: lparam Pin
Waldermort10-Sep-06 8:09
Waldermort10-Sep-06 8:09 
GeneralRe: lparam Pin
Jörgen Sigvardsson10-Sep-06 13:44
Jörgen Sigvardsson10-Sep-06 13:44 
QuestionHow can I combine two hex values into one integer value? Pin
TylerD7510-Sep-06 7:24
TylerD7510-Sep-06 7:24 
I've got two HEX values: 0x4D and 0x5A
I want to combine them (not add them together), so that I have an unsigned short variable with the value 0x4D5A (= 19802).

How can I accomplish this?

To be a little bit more specific:
1. I've got a temp array (unsigned char tmp[1];) where each byte in a binary stream passes through.
tmp[0] = br->ReadByte();<br />
tmp[1] = br->ReadByte();


2. I've made a struct like this:
<br />
struct EXE {<br />
	unsigned short signature;<br />
	unsigned short bytes_in_last_block;<br />
	unsigned short blocks_in_file;<br />
	unsigned short num_relocs;<br />
        unsigned short header_paragraphs;<br />
	unsigned short min_extra_paragraphs;<br />
	unsigned short max_extra_paragraphs;<br />
	unsigned short ss;<br />
	unsigned short sp;<br />
	unsigned short checksum;<br />
	unsigned short ip;<br />
	unsigned short cs;<br />
        unsigned short reloc_table_offset;<br />
	unsigned short overlay_number;<br />
	void dbgPrintToConsole()<br />
	{<br />
		Console::WriteLine(L"Signature -            HEX : 0x{0:X}", signature);<br />
		Console::WriteLine(L"Bytes in last block        : {0}", bytes_in_last_block);<br />
		Console::WriteLine(L"Number of blocks in file   : {0}", blocks_in_file);<br />
		Console::WriteLine(L"Number of Relocations      : {0}", num_relocs);<br />
		Console::WriteLine(L"Header Paragraphs          : {0}", header_paragraphs);<br />
		Console::WriteLine(L"Minimum Extra Paragraphs   : {0}", min_extra_paragraphs);<br />
		Console::WriteLine(L"Maximum Extra Paragraphs   : {0}", max_extra_paragraphs);<br />
		Console::WriteLine(L"SS register start-value    : {0:X}", ss);<br />
		Console::WriteLine(L"SP register start-value    : {0:X}", sp);<br />
		Console::WriteLine(L"Checksum (usually not used): {0:X}", checksum);<br />
		Console::WriteLine(L"IP register start-value    : {0:X}", ip);<br />
		Console::WriteLine(L"CS register start-value    : {0:X}", cs);<br />
		Console::WriteLine(L"Relocation table offset    : {0:X}", reloc_table_offset);<br />
		Console::WriteLine(L"Overlay Number             : {0}", overlay_number);<br />
	}<br />
};<br />


So what I'd like to do, is to assign every two bytes into the unsigned short variables in the struct EXE.

I should probably mention that I am a VC++ newbee.

Hope this makes sense to someone?

Cheers,
TylerD75
AnswerRe: How can I combine two hex values into one integer value? Pin
Waldermort10-Sep-06 8:06
Waldermort10-Sep-06 8:06 
GeneralRe: How can I combine two hex values into one integer value? Pin
TylerD7510-Sep-06 8:20
TylerD7510-Sep-06 8:20 
GeneralRe: How can I combine two hex values into one integer value? Pin
Waldermort10-Sep-06 8:26
Waldermort10-Sep-06 8:26 
AnswerRe: How can I combine two hex values into one integer value? Pin
TylerD7510-Sep-06 8:06
TylerD7510-Sep-06 8:06 
QuestionUsing GTK+ with Visual C++ Express. Pin
delphidab10-Sep-06 7:19
delphidab10-Sep-06 7:19 
AnswerRe: Using GTK+ with Visual C++ Express. Pin
Jim Crafton10-Sep-06 15:00
Jim Crafton10-Sep-06 15:00 
GeneralRe: Using GTK+ with Visual C++ Express. Pin
delphidab10-Sep-06 19:32
delphidab10-Sep-06 19:32 
Questioncopy a folder, delete a folder Pin
FredrickNorge10-Sep-06 5:14
FredrickNorge10-Sep-06 5:14 
AnswerRe: copy a folder, delete a folder Pin
Gary R. Wheeler10-Sep-06 5:20
Gary R. Wheeler10-Sep-06 5:20 
GeneralRe: copy a folder, delete a folder Pin
FredrickNorge10-Sep-06 5:30
FredrickNorge10-Sep-06 5:30 
AnswerRe: copy a folder, delete a folder Pin
Hamid_RT11-Sep-06 5:54
Hamid_RT11-Sep-06 5:54 
QuestionProblem with CPP Statement Pin
Semion_N10-Sep-06 5:12
Semion_N10-Sep-06 5:12 
AnswerRe: Problem with CPP Statement Pin
Waldermort10-Sep-06 5:27
Waldermort10-Sep-06 5:27 
GeneralRe: Problem with CPP Statement Pin
Semion_N10-Sep-06 5:59
Semion_N10-Sep-06 5:59 
GeneralRe: Problem with CPP Statement Pin
Waldermort10-Sep-06 6:50
Waldermort10-Sep-06 6:50 
AnswerRe: Problem with CPP Statement Pin
Gary R. Wheeler10-Sep-06 5:30
Gary R. Wheeler10-Sep-06 5:30 
GeneralRe: Problem with CPP Statement Pin
Semion_N10-Sep-06 7:06
Semion_N10-Sep-06 7:06 

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.