|
Try a union :
<br />
typedef union<br />
{<br />
ULONG itemlong;<br />
UCHAR itemchar[4];<br />
} UnionLong;<br />
then you can swap the bytes through a temporary variable.
a two cent stamp short of going postal.
|
|
|
|
|
Didn't thought of a union
But even swapping with the xor trick I'm not sure how the compiler optimization would be. I guess looking at the asm code would make the final judgement.
Thanks.
Jürgen Eidt
http://cpicture.de/en
|
|
|
|
|
unsigned long Swap(unsigned long value)
{
return ((value & 0xFF000000) >> 24) |
(value & 0x00FF0000) >> 8) |
(value & 0x0000FF00) << 8) |
(value & 0x000000FF) << 24);
}
Software Zen: delete this;
|
|
|
|
|
|
You're welcome. If you make the function inline , the compiler will compile it in place without the function call overhead (I forgot to do that).
Software Zen: delete this;
|
|
|
|
|
Of course inline!
Actually you can remove the masking for the 24 bit shifts. For the inner two bytes I don't see an improvement.
Thanks Gary for the follow up
Jürgen Eidt
http://cpicture.de/en
|
|
|
|
|
I need help in .cpp and .h implementation code for the 8 bit binary addition.
The program has to handle additions of both positive and negative binary strings with the following assumptions:
The first string is stored using two's complement and the second using 8-bit bias notation. The result should be a bit string in two's complement (including a decimal interpretation of the result). I even have to keep track of overflow condition.
It would be great if you can send me the code.
|
|
|
|
|
I think you would probably learn much more if you were to do your own homework than if someone else were to do it for you.
a two cent stamp short of going postal.
|
|
|
|
|
Hello,
I have not done MFC programming for quite awhile and am now undertaking a (sort of) relearning process.
Could someone tell me if I can implement a certain process in InitInstance (derived from CWinThread) without freezing the OS, i.e. a drive parser which looks for certain files to analyse & update.
Also, if you are in possession of a good knowledge about Threads (specifically CWinThread) would you mind telling me a bit about how it works in a general way?
Thank you for taking the time.
David
dNimrod#X
________________________
|
|
|
|
|
dNimrod#X wrote:
Could someone tell me if I can implement a certain process in InitInstance (derived from CWinThread) without freezing the OS, i.e. a drive parser which looks for certain files to analyse & update.
I guess you can. As long as you provide a way to inform your application's user about what the hell is happening i.e. why is it taking too long. are you getting my point? (Ofcourse, I am talking about interactive applications)
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
Gurmeet S. Kochar wrote:
I guess you can. As long as you provide a way to inform your application's user about what the hell is happening i.e. why is it taking too long. are you getting my point? (Ofcourse, I am talking about interactive applications)
Yes I understand your point but what I am not sure about is if the dialog box's controls will still be accessible while the disk drive parsing is running. I mean, the question now is whether or not the dialog box will not freeze (if the message proc will still handle messages from the dialog box) ?
Ravi Bhavnani wrote:
Yes. But you will probably want to create the file search and analysis as a separate thread.
Do I really have to?
Thanks a lot for your replies and for taking the time.
dNimrod#X
________________________
|
|
|
|
|
Yes. But you will probably want to create the file search and analysis as a separate thread.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
i have two questions:
1) how do i go about creating a gui for a dos (not dos-mode) application? ie. what program do i use to creat this?
2) if i don't want to make a gui then what do i need to make a command based application in dos? and are .exe and .com the same thing?
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
1) DOS has not a gui support, you need a third party library like Borland's Turbo Vision (text mode windows) or other.
2) All reasonable programing tools (Turbo Pascal, C/C++) for dos can create command-line programs.
Pavel
Sonork 100.15206
|
|
|
|
|
i know dos doesn't have a gui support....so how do i make one? ex. i've seen some bios screens that have a gui.
i made a console app in c# but i guess it won't run in dos. can i make a console app in c++ .net or c++ 6.0?
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
certainly ,you can make a console app in c++ 6.0.and you can make a gui like some bios screens .In visual c++ 6.0 you can't use windows classes like CWnd .
i'm software engineer
|
|
|
|
|
You might want to try these (somewhat dated) packages:Check out other links here[^]. Good luck!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi all,
In a dialog, is it possible to align a control with layout guidelines such that if the dialog is resized, the conrol is also resized accordingly?
Mark
|
|
|
|
|
|
Hi there,
I am writing an application where I want to open a file... but not via CWinapp:OnOpenFile() , I do my own DoPromptFileName() .
My problem now (maybe very simple): How do I tell the OpenFileDialog, IN WHICH DIRECTORY it should start?
Example:
I got two different file-types to handle, one "*.abc" and the other "*.def". I also got two buttons, A = "Open ABC-file" and B = "Open DEF-file".
Now I have two default folders, maybe "C:\files\abc\" and "E:\Files\def\" where the files lay.
Now how do I tell the OpenFileDlg to initially browse in the "C:\files\abc\"-folder when pressing Button A, but browsing folder "E:\Files\def" when pressing button B?
I hope everyone understood my problem and anyone out there can help me...
Thanks in advance!
Tiberius
----------------------------------------------------------
I once had a nightmare in binary --- I think there was a 2
|
|
|
|
|
SetCurrentDirectory
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
thanks for your help, but that wasn't it...
my situation:
I handle videofiles and they are in C:\video\. I opened one from there some time befor and now I want to open another video from a location I want to set beforehand. so I tried this (just for testing):
<br />
CString newName = "";<br />
if(SetCurrentDirectory("D:\\"))<br />
AfxMessageBox("yep");<br />
else<br />
AfxMessageBox("nope");<br />
<br />
DoPromptFileNames(newName, AFX_IDS_OPENFILE,OFN_HIDEREADONLY | OFN_FILEMUSTEXIST , TRUE, NULL, "MPG-Video", "mpg");<br />
The message I got was (surprise, surprise) "yep", so I thought, OpenFileDialog would browse "D:\" but - pow! - it went straight to "C:\videos\"...
any other idea ?
Thanx!
Tiberius
----------------------------------------------------------
I once had a nightmare in binary --- I think there was a 2
|
|
|
|
|
Unfortunately, setting the current directory won't work because Windows stores default dirs for the file open dialog in the registry (on a per extension basis).
You can make the standard Open/Save File dialogs use a custom initial directory by setting the lpstrInitialDir member of the dialog's OPENFILENAME struct. See this MSDN link[^] for details.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks !!!
----------------------------------------------------------
I once had a nightmare in binary --- I think there was a 2
|
|
|
|
|
Does anyone know of an API that will return the localized descriptive name of a language, given its language id? Eg: ZH_CN = "Simplified Chinese", ZH_TW = "Traditional Chinese", etc.
Or is this information stashed somewhere in the registry?
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|