|
anyone got a sample of how I can put the large array/data structure in a resource? looked around but not finding anything
|
|
|
|
|
|
Use fwrite instead of fprintf.
|
|
|
|
|
Regarding the null terminating character being embedded within the source/custom resource, I'm having some difficulty getting fwrite to continue past embedded 0x00 values in my data...
Someone posted earlier:
It acted like it continued beyond the end of the array until it came across the zero byte in memory. I put the "\0" or the 0x00 and it stopped exactly where I told it too. This raises the question, if that array is supposedly a hex representation of an exe, how are you getting away without stumbling across 0x00 somewhere in the binary string? this is one of the reason they tell us to encode binary data when using a null terminated string to contain it.
My code:
char * cStr = reinterpret_cast< char *>(lpVoid);
cStr = strncat(cStr, "\0", 1);
printf("size of cStr%d\n", sizeof(cStr));
FILE * stream;
if( (stream = fopen( "fread.out", "w" )) != NULL )
{
int num_write = 0;
num_write = fwrite( cStr, sizeof( cStr ), 1, stream );
printf( "Wrote items: %d\n", num_write );
fclose( stream );
}
Results:
follwing were writing sizeof(cStr) - 1 (not wanting to write the trailing null to our output file):
testing: 4d 5a 90 as input, output: 4d 5a 90 (OK)
testing: 4d 5a 90 00 as input, output: 4d 5a 90
testing: 4d 5a 90 00 03 as input, output: 4d 5a 90
testing: 4d 5a 90 03 as input: output: 4d 5a 90
writing sizeof(cStr) :
4d 5a 90 -> 4d 5a 90 00
4d 5a 90 00 -> 4d 5a 90 00
4d 5a 90 00 03 -> 4d 5a 90 00 (stripped trailing character)
Anyone have any suggestions on how to proceed?
How will the program know the difference between the trailing null at the end of the string versus embedded nulls?
|
|
|
|
|
Hello.
Apart from being said in your latest post on the subject, you will have to keep track of the length of the data.
There is no way to know (at this level) if a "zero-byte" is supposed to be a char array terminator or if the "zero-byte" is supposed to be written in the file.
In addition to lpVoid, you must have a "lpVoidDataSize" variable.
And then do this:
fwrite( cStr, sizeof(char), lpVoidDataSize, stream );
|
|
|
|
|
i have an excell sheet as a database, what is the complete code in c# to read my database?
|
|
|
|
|
raniam wrote: visual c#
Oops. Wrong discussion board. C# is too safe for us. We like livin' on the edge on this side of town.
Try the C# board...
C#[^]
|
|
|
|
|
Hi,
I have a problem with the subitem character size.
When I insert a subitem (or item) with more of 255 character size, this control only show the first 255 characters.
How to insert a subitem with more of 255 character length?
Ivan Cachicatari Blog[^]
www.latindevelopers.com
|
|
|
|
|
Hmm. I never noticed that before but you are right.
Somebody posted this link elsewhere in CP about a bug. I'm not sure if it'll help you but here's the link...
From FredBloggsy[^]
-- modified at 17:47 Sunday 28th May, 2006
By the way, I was on VC++ 6.0 when I reproduced it so it seems it's in all versions. It does seem to be a "reasonable" limit for the most part.
|
|
|
|
|
CString Test = "Remove the word TEST"
how i remove the TEST ?
so i gonna have
CString Test = "Remove the word "
|
|
|
|
|
CString sData="Remove the word TEST";
CString sWord="TEST";
int nIndex=sData.Find(sWord,0);
if (nIndex!=(-1)) { // Found it
sData.Delete(nIndex,sWord.GetLength());
}
TRACE("%s",sData);
|
|
|
|
|
thank you very much bob16972 you helped me much today
|
|
|
|
|
Another method is :
CString Test = "Remove the word TEST";
Test.Replace("TEST","");
|
|
|
|
|
That'll remove every instance of the word "TEST". The other will remove the first instance only.
Just a heads up for the sake of clarity.
For what it's worth...
|
|
|
|
|
yes that is true, btw what she/he wanted exactly ?
|
|
|
|
|
Honestly I'm not sure at this point. You were right in posting your stuff. I wasn't jumping on it. I just threw in the clarification for they're benefit so they knew the implications of each method.
Sorry if I approached that wrong. It never dawned on me that the user might want all instances removed so I'm glad you caught that.
Thanks and take care.
|
|
|
|
|
bob16972 wrote: That'll remove every instance of the word "TEST". The other will remove the first instance only
In that case how will he/she determine which TEST keyword he have to removed
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi All,
I have a formview app with a propertypage imbeded in a nother property page.
How do I link this to a menu?
Any help would be greatly apreciated.
Ferdinand
|
|
|
|
|
A formview app should have a menu already. Are you asking how to make menu items do something in your formview?
If you could provide a little more detail describing the problem and context, I would be less reluctant to post a suggestion.
Thanks
|
|
|
|
|
Yea, I'm trying to link menu items provided by the app wizard to dynamic property page within a property page.
|
|
|
|
|
Ok, it's been a while since I messed with these but I found an app and got my trusty old Jeff Prosise book out and the rust is started to give a little.
Forgive me if I'm off a little at first but you say "menu items provided by the app wizard". Are you using VC++ 6.0 or VC++ 2003 or VC++ 2005? I'm thinking your referring to the MFC wizard DDX/DDV stuff but I afraid to go that route without confirmation.
I'm thinking of a dialog resource that needs it's fields "bound" to member variables for the Propert Page class. Let me know if I'm on or off target here.
|
|
|
|
|
Hi Bob,
First, Thanks for the help.
I'm using VC++ 6.0. When I use the app wizard, It places the command handlers in the correct class, but the menu items are still greyed out.
|
|
|
|
|
Is this what your looking for?
void CYourFormView::OnUpdateSomeMenuItem(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
if (Some expression that resolves to TRUE if menu should be enabled)
pCmdUI->Enable(TRUE); // Enable the menu item
else
pCmdUI->Enable(FALSE); // Disable the menu item
}
-- modified at 1:38 Monday 29th May, 2006
|
|
|
|
|
Actually, I was looking for something more like this.
IMPLEMENT_DYNCREATE(CMYView, CFormView)
BEGIN_MESSAGE_MAP(CMYView, CFormView)
ON_WM_SIZE()
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_SAVEAS_TEXT, OnSaveasText)
N_UPDATE_COMMAND_UI(ID_SAVEAS_TEXT, OnUpdateSaveasText)
END_MESSAGE_MAP()
If placed in the view class everything works fine. However, if this is placed in an embeded class, I don't recieve the messages in that class. and nothing happen.
|
|
|
|
|
unfortunately I cannot see a way to make that work. At least not directly.
I googled and found some articles relating to ON_UPDATE_COMMAND_UI and dialogs. WM_KICKIDLE gets tossed around quite a bit in those articles but it's somewhat over my head I think.
I'm leaning toward the CFormView ON_UPDATE_COMMAND_UI handler since it can see the PropertySheet/Pages public info. Any decisions that influence the results of the ON_UPDATE_COMMAND_UI you planned in the PropertySheet/Pages could still be performed in the CFormView.
Sorry that I wasn't able to provide any help on the matter. I did piece a FormView app like you described and tried brute forcing it but it seems much more complex than I anticipated.
Good luck in your efforts.
|
|
|
|