|
|
Does anyone how to wire up a pointer to access a certain part of of a data field. Such as:
<pre>usnigned short int x;
((char *) &x)[0];</pre>
to access the first byte in a 16 bit operand.
|
|
|
|
|
char *pChar = (char*)&x;
Access through pChar[0] or *pChar
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
You have no idea how much you just helped me. I don't know why that was so hard for me to figure out. I have been working on this all weekend trying to get ready for a test on it tomorrow. Pointers have always been somewhat confusing for me. But the more I play with them them more they are starting to make sense.
Now could you give me an example on how to make this work using a struct? The book I have is so vague or hard for me to understand.
|
|
|
|
|
Quickie posting tip, since I've noticed a pattern in a lot of your posts...
If you use the "Do no treat <'s as HTML tags" option, you don't need to use <pre> tags around your code. Use the "Preview" button to check what your post will look like before clicking "Submit".
- Mike
|
|
|
|
|
Hello all,
I have a duplex wait pipe Client which after a couple write/read operations in Release build only return either 131 (An attempt was made to move the file pointer before the beginning of the file.) or 183 (Cannot create a file when this file already exists.).
I use CreateFile(CLIENTTOPLATPIPE, GENERIC_READ|GENERIC_WRITE, 0, NULL,OPEN_EXISTING,0,NULL); to open the pipe and a buffer of size 5120 to write data in Byte mode.
Any insights?
Thank you in advance.
Alberto Gattegno
Software Engineer
http://www.itgil.com
|
|
|
|
|
Hello,
I have a CPropertySheet with a few property pages embedded in a form view. I would like to capture the WM_ACTIVATE message to see when I should write/read data from/to property pages. The problems is the the form view is eating up that message. I can only monitor WM_CHILDACTIVATE and OnKillActive(), but that doesn't cover all cases. I want to save data whenever a user clicks away from the property sheet. How can I do that?
Any help greatly appreciated!
MCP, MCSD
|
|
|
|
|
Override OnSetActive() when you want to (re)set the property page's controls. Override OnKillActive() and OnOK() (and optionally OnApply() ) to capture the settings from the property page.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Well, I did that, but it doesn't cover all cases I want - for example, when a user simply clicks away from my property page to another control on the form view, I want to save data he had in the pp.
MCP, MCSD
|
|
|
|
|
Ah, so your property sheet is a modeless one, and is a child of your form view. You could set a timer that does what OnKillFocus() would do, each time the property sheet loses (i.e. no longer has) focus. I admit the solution reeks of cheddar, but it would work.
But I think there may be something fundamentally wrong with your UI design if you need to do this. What might be more appropriate is updating your data every time the user tweaks a control within the property page(s). That way (a) you won't have to query the state of the controls and (b) your data will always be in synch with the GUI.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Well, the form view has the property sheets and a grid control, so when a user clicks on something in the grid, data gets updated in the property sheets, but it has to be saved when changed in the property sheets and displayed in the grid. So, that's the problem I have - to find out when the user clicked away from the property page, so that I could update the grid BEFORE the click gets there and resets the data.
I don't know if it's wrong UI design, but I couldn't think of any other way to accomplish this?
But I was thinking about updating the data after each control change, but I wanted to stay away from that path for as long as possible, since I have 6 property pages with around 50 controls, so that would be a lot of handler functions
MCP, MCSD
|
|
|
|
|
|
But aren't these two messages what the OnSetActive() and OnKillActive() MFC functions do?
You see, I need the control to generate something when the user clicks away from it, not just changes to another property page.
MCP, MCSD
|
|
|
|
|
Does handling WM_SETFOCUS / WM_KILLFOCUS help you?
(For me, it does not, because the controls get no WM_KILLFOCUS when the user clicks a Toolbar-button - probably the button does not accept the focus)
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
No, these messages are not sent to propery pages.
MCP, MCSD
|
|
|
|
|
dennisV wrote:
No, these messages are not sent to propery pages.
I know, you would have to do that yourself, using handlers in the sheet that re-send the message to the pages. (You could as well have the sheet send a private message (WM_APP+xx or a registred WM)
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Well, I've tried capturing WM_KILLFOCUS and it doesn't reach the CPropertySheet That's the original problem I have - normal messages are eaten up by the CMainFrame and never reach anywhere. That's why WM_ACTIVATE doesn't work as well...
MCP, MCSD
|
|
|
|
|
WM_KILLFOCUS does indeed reach a PropSheet. I do handle it there.
If CFormView really eats it, re-send it in your CFormView derived class.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Well, WM_KILLFOCUS is caught in the CFormView, but I have no way of knowing (or at least I don't know of a way) to determine which window lost the focus, so I don't know to which window to send it. I have a property sheet and a grid control on my CFormView, and I need to determine when the property sheet looses focus, but OnKillFocus() provides a pointer to the new window, not the window that lost focus. Or is there a way to find out which window lost focus?
Thanks for your help!
MCP, MCSD
|
|
|
|
|
Well, now I am out of luck. You *could* try to call CWnd::GetFocus() to determine which control currently has the focus.
But I do not know if this works.
Sorry, without CFormView your sheet can catch WM_KILLFOCUS, and that is what I do.
My only problem is that clicking a toolbar-button does not remove the keyboard focus from the control on my property page.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Yes, without the CFormView things worked for me too. That's why I got stuck when I implemented the CFormView. Perhaps it's an MFC bug or something... I think I'll go complain to MS, although that probably won't help me
MCP, MCSD
|
|
|
|
|
dennisV wrote:
I think I'll go complain to MS, although that probably won't help me
They will thell you its the intended behaviour (its intention is to save programming time to fix the bug ).
Then they will tell you how nice .NET is...
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
jhwurmbach wrote:
They will thell you its the intended behaviour
Right
Oh well, I guess I'll do it the old-fashioned way, until I can find a solution - I'll just add an event handler for every change in every control and save data then. At least it won't be lost then.
Thanks again for your help!
MCP, MCSD
|
|
|
|
|
printf("\nEnter Database Path and File name: ");
fgets(File, 250, stdin);
what shud be the input for the above statement on execution??
ranjani
|
|
|
|
|
The input will be whatever is typed. Perhaps you meant to ask something else.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|