|
Ok. Let's back up a bit. I'm not sure if you have a scrollbar or your dealing with the scrolling in a view so I'm going to take some liberties here and assume for the moment that your wanting to scroll a view.
Start a new MFC/SDI app and take all the defaults except on the last screen derive your class from CScrollView.
In the CYourView::OnInitialUpdate() you'll find some code that sets the scrollsizes to some default values. CWnd provides some functions similar to CScrollBar's methods. Modify the code to look something like the following...
void CYourView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 2000;
this->SetScrollSizes(MM_TEXT, sizeTotal);
this->SetScrollPos(SB_HORZ,500);
this->SetScrollPos(SB_VERT,400);
}
Mess with this a for a bit. Lookup the scrolling functions for CWnd and try some of the other functions and mess with the parameters. the this-> pointer is implied but I included it to demonstrate that we're using members of CView. since CView does not have these members, you goes up the object hierarchy to CWnd which has them.
Sorry about any confusion I may have caused or introduced inadvertantly.
-- modified at 21:28 Sunday 28th May, 2006
|
|
|
|
|
I dont have a scroll bar in my dialog :P
I got a List Box with Vert scroll Property
When the List box fill up then a Vertical scroll pop up but it always scroll to the top (while the new items /lines are pop in the bottom of the list box)
So i have the scroll on the top (the view of the old/First lines)
And i want to make the scroll bar to scroll down
Sorry for my newbieness
|
|
|
|
|
if your app has a member variable for the listbox named m_List then this might get you going.
CString sListEntry="";
int nMin=0;
int nMax=0;
for (int i=0;i<50;++i) {
sListEntry.Format("Item %02d",i);
m_List.AddString(sListEntry);
}
m_List.GetScrollRange(SB_VERT,&nMin,&nMax);
TRACE("Min = %d\nMax = %d\n",nMin,nMax);
m_List.SetScrollPos(SB_VERT,nMax/2);
-- modified at 22:40 Sunday 28th May, 2006
|
|
|
|
|
I'm having some problems compiling this:
[pre]
FILE * stream;
unsigned char data[] = { 0x40, 0x5A ......... }; // approximately 50000 elements (bytes in destination file)
stream = fopen("lgt.exe", "w" );
fprintf(stream, "%s", data);
fclose(stream);
[/pre]
I gave it an hour to compile but its still chugging along. cl.exe is 100% CPU but virtual memory usage is unchanged at about 23MB.
Note: I can't use any .NET functions since not all target clients running my app will have .NET
Is my array too big? What might an alternative approach be (one that will compile)..
Thanks
|
|
|
|
|
|
I vaquely recall the stack limit per thread being something like 1 meg. This was from some MFC Network Programming book that came with a 1.44Meg floppy so it may be a little outdated but I think it was for NT.
Is it smaller than 1 Meg on WinNT?
|
|
|
|
|
fprintf will expect "\0" at the end of that array I think
-- modified at 20:21 Sunday 28th May, 2006
No, I retract that statement. I just ran your snippet with a teeny tiny array and it worked fine so sorry for the impulse post. I stand corrected
-- modified at 20:23 Sunday 28th May, 2006
Ok one more time, I retract my retraction. The output file had more than I had in my array. 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.
Interesting.
|
|
|
|
|
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
|
|
|
|