|
Hi all,
I have a struct a bit like this, which is the header to a file on disk:-
struct Header
{
short a;
short b;
short c;
float floatvalue;
}
I read the header from the disk like this:-
ReadFile(hFile,&header,sizeof(Header),&bytesRead,NULL);
Once I'd done that, the values in a,b,c are as expected, but the floatvalue is not.
However, if I adjust the struct so that instead of float, I have BYTE[4] as follows:-
struct Header
{
short a;
short b;
short c;
BYTE floatvalue[4];
}
And then after reading the header as before, I do:-
float f;
memcpy(&f,header.floatvalue,sizeof(float));
Then f contains the value expected.
I don't understand why the first version didn't work. Can anyone enlighten me please?
Thanks
Jon
|
|
|
|
|
Maybe take a look at this[^], i hope it explains what you need explained.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thank for that, it's clear now.
Looks like a can get around the issue with #pragma pack (2)
|
|
|
|
|
I think that a
#pragma pack (1) or
#pragma pack (2) declaration before the structure's definition would help. Think so?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Hello Team,
I have written a C++ program, which will fetch the MAC address using the GetAdaptersInfo, and this program is compiled using gcc of mingw. when i run this program in my PC, this has return valid MAC. Everything fine.
But When I run same program , where I had a wifi card and a LAN card, this program returend both the MAC address. In my program i am chacking for MIB_IF_TYPE_ETHERNET, still it is giving both the MAC.
How do i get only MAC of LAN card ? not wifi / bluetooth card?
Thank you
glamakid
|
|
|
|
|
You could try using WMI[^] and retrieving <a href="http://msdn.microsoft.com/en-us/library/aa394216%28VS.85%29.aspx" rel="nofollow">Win32_NetworkAdapter</a> [^] instances whose AdapterType is Ethernet 802.3 ?
WMI at least separates out wireless adapters.
|
|
|
|
|
Hello
Thank you . Cant I use the GetAdapter...API itself? I am not good at usign WMI program
glamakid
|
|
|
|
|
The documentation and your experience indicate that you can't. I'm guessing that at that level of abstraction, WiFi is close enough to ethernet that they can be treated the same.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello Stuart,
I am getting both the adapter, but i want only the ethernet adapter. how can i supress the other one ?
|
|
|
|
|
As I said before, I think WIndows treats WiFi (and Bluetooth, judging from what I've seen) as Ethernet interfaces at this level of abstracvtion. You need to find some interface that's closer to the hardware that allows you to make adefinitive statement about whether an interface is 802.3 or not.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I have inserted media player activex on my dialog box, using OnPositionChangeOcx1 event i am able to get the audio slider bar position, now i want to set the slider position to some where in the slider bar.
I am not able to do that, i don't know which function i have to use for setting, becuase i am very new to this ActiveX environment..
Can any one help me regarding this..?
Your help will be appriciated...
Thanks in advance.....
Thanks
Venkatesh.
|
|
|
|
|
venki502 wrote: I have inserted media player activex on my dialog box
If you are going to use the media player activeX control in your application you might want to consult the documentation[^]
|
|
|
|
|
I like the "let me Google it" thing. Nice touch. I can't believe I haven't come across it before.
Steve
|
|
|
|
|
Stephen Hewitt wrote: I can't believe I haven't come across it before.
That's exactly what I said when I saw someone else here had used it.
|
|
|
|
|
Hi,
I have created one application in VC++, in that am using one edit box to display the values , i hav created a member variable for that edit box in that defined double datatype. My question is , if i get any exponential value, it is not displaying fully, it displays upto the size of the edit box. is there any way to see the exponential value in the edit box
Thanks,
Balaji S
|
|
|
|
|
I think CEdit is not directly support that. You can use %e or %g to format it as string and set as window text to edit control
e.g
float f = 100.234235454;
CString str;<br />
str.Format( "%e", f );<br />
editCtrl.SetWindowText( str );
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
modified on Tuesday, February 10, 2009 5:57 AM
|
|
|
|
|
Sarath. wrote: float f = 100.234235454; // some value
CString str;
str.Format( "%e", f );
editCtrl.SetWindowText( f );
I think you mean this:
float f = 100.234235454;
CString str;
str.Format("%e", f);
editCtrl.SetWindowText(str);
Steve
|
|
|
|
|
Yeap... It was a typo
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Okay this one is for the Gurus!
I am trying to open multiple modal dialogs from a parent modal dialog. However, in modal dialogs only one child dialog can be opened at a time under a parent dialog. Therefore, I have to use the applications main window to have multiple modal dialogs opened and use a map to track which dialogs belong to the parent dialog.
How can I get a handle or pointer to the childrens dialog windows to store them in my map (for the parent to track)?
My goal is to close all the parent's children dialogs once the parent's has been closed. And also consistently close them out by calling theDlg->EndDialog(IDOK) when the parent dialog has been closed by clicking "OK" or theDlg->EndDialog(IDCANCEL) when the parent dialog has been closed by clicking "Cancel".
|
|
|
|
|
AeJai wrote: I am trying to open multiple modal dialogs from a parent modal dialog
Multiple modal dialogs...so, which is active - there can only be one at a time. Also, once a modal dialog starts, the only way for it to communicate with its parent window is by exiting - it contains its own message loop rather than using its parent window's message loop.
AeJai wrote: My goal is to close all the parent's children dialogs once the parent's has been closed
A parent window cannot be closed if it has spawned a modal dialog.
Just don't do it - 'multiple modal dialogs' is really a synonym for 'modeless dialogs', IMO. You can close the child modeless dialogs by posting WM_CLOSE messages to them, IIRC.
|
|
|
|
|
The reason the parent window can be closed is because its parent too is the main window's (i.e., (long)AfxGetMainWnd()->m_hWnd) as well as its children. This allows for all the modal dialogs to open and not continue in the code sequentially until OK or Cancel has been clicked.
I need to open more dialogs from this parent dialog in order to compare and modify values (of the contents). I cannot use modeless dialogs because it continues computing without the user selecting OK or Cancel; it just creates the dialog and will create multiple dialogs of the same type or instance rather. I have been able to reactivate the dialog that has been opened already by using a PropertyFrame pointer.
I cannot just close the dialogs via WM_CLOSE, but should prevent the parent dialog from closing as long as its children dialogs are opened. That too will be as difficult.
|
|
|
|
|
I want to transform a modal dialog box into a modeless so I can drag and drop items from the interface in the main window (in a SDI application) into my dialog box. That bit, I can do - I allocate dynamically the dialog box and call CreateWindow. But I don't want the user to be able to click on the menu or the toolbar (or about anywhere actually except a treecontrol where the drag & drop will start from).
Is this achievable without having to add code on every single menu handler?
Thanks in adavance!
|
|
|
|
|
In general, you'd use ON_UPDATE_COMMAND_UI handlers to disable the menu commands and associated toolbar buttons. You could have a single handler method to deal with all the menu commands, but you'd have to declare them all in the appropriate message map.
|
|
|
|
|
Hi Stuart,
Thanks for this - but I do not want to have to write a handler / or modify existing handlers for every single of them!
|
|
|
|
|
You don't have to - write one method to handle the ON_UPDATE_COMMAND_UI thing, then register that one (ONE) method for all the ON_UPDATE_COMMAND_UI things you need to handle.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|