|
Take a look at the COSERVERINFO structure in CoCreateInstanceEx.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
What would I have to do to use high color bitmaps in a CToolbar...?
I created a app with the wiz and tried changing the bitmap to a high color, but because CToolbar uses the 192,192,192 RGB color of 16 color toolbar bitmaps as a substitution color i'm assuming high colors won't work...?
Cuz well they didn't when I tried, unless i'm doing something wrong...?
I'm thinking I should just design a toolbar from scratch (CControlbar) and handle the loading of the bitmaps and all that stuff.
Should I pick apart CToolbar in MFC or does anyone know really cool toolbars I can use as example.
Anybody suggestions...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
You can use CToolBarCtrl::SetHotImageList and CToolBarCtrl::SetImageList to set the double color 24 bit toolbars
Nish
Yeah that's me down below
|
|
|
|
|
I just figured that out.
However i'm in need of something to do so I figure i'll tackle a custom 24 bit toolbar just for the heck of it.
Thanx Nish.
Is that your Johnny Denver...fever...??? what was it...?
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
Is that your Johnny Denver
Johnny Bravo
Nish
Yeah that's me down below
|
|
|
|
|
Hi.
I would like to know how to change (repaint) a new color for a CButton object, both group and/or options.
For example:
...
CButton mBtnGreen;
...
mBtnGreen.Create("Green", WS_CHILD | WS_VISIBLE | BS_CHECKBOX
CRect(CPoint(0, 0), CSize(25, 50)), this,
IDC_BTNOPT_GREEN);
...
By default, the color of option (button) "Green" is light gray, like cream. I would like to change the color of the background of the button and/or text. By default, the text is black.
I tried repaint the entire client area, but MFC ignores the button areas.
Thanks,
Kuphryn
|
|
|
|
|
1) ownderdrawn
2) Subclass
Chris has an article that should meet your requirements nicely.
Custom button
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Anyone have any idea how to find how much space my CObject derived class is taking or will take up once its serialized?
I've serialized an object then manually written raw data at the end of the file. This works fine, but when I read it back, i figured I could serialize the object and pick up where the file pointer left off, but nope.
I forgot that CArchive allocates a buffer and reads in chunks so, i can't assume that the file pointer is immediately after the object i just serialized.
So, i need to find out what the actual disk space of my object is - any ideas?
Marcus Spitzmiller
"Ha ha, Stupid bloropope.." - Homer
|
|
|
|
|
I seriously wouldn't advise that Marcus.
It's not a good idea.
You might end up corrupting the serialized objects
Nish
Yeah that's me down below
|
|
|
|
|
Hmmm....I'm in a pickle, then.
Maybe you've tried this sort of thing, then. Basically I'm writing an object to a file as a header then appending various other files to create a large file. Basically, minus error checking:
fOut.Open(strFileOut,
File::modeCreate|CFile::modeWrite|CFile::shareDenyNone, &Error);
//the header
CArchive ar(&fOut, CArchive::store);
m_objInstrument.Serialize(ar);
//then i append the files
for(int i = 0; i < arFileNames.GetSize(); i++)
{
strFileName = arFileNames.GetAt(0);
arFileNames.RemoveAt(0);
fIn.Open(strFileName, CFile::modeRead, &Error))
dwLength = fIn.GetLength();
BYTE * pBuf = (BYTE *)malloc(dwLength);
fIn.Read(pBuf, dwLength);
fOut.Write(pBuf, dwLength);
fIn.Close();
free pBuf;
}
fOut.Close()
So you're saying this is a bad idea? Wait..I just noticed the CArchive::Write method...Interesting. I'm going to give this a try, but in the meantime if you have any suggestions, please feel free to let me know.
Marcus Spitzmiller
"Ha ha, Stupid bloropope.." - Homer
|
|
|
|
|
Here is something you could try:
CMemFile file;
CArchive ar(&file, CArchive::store);
pYourObject->Serialize(ar);
ar.Close();
DWORD dwSizeOfYourObject = file.GetLength();
file.Close();
I haven't tried it, so may be this would give you a size that is a multiple of nGrowBytes (parameter of the constructor of CMemFile, 1024 by default).
Hope this helps,
David Defoort
|
|
|
|
|
Thanks, David - I'll give that a go, and get back to you.
Marcus Spitzmiller
"Ha ha, Stupid bloropope.." - Homer
|
|
|
|
|
what does this mean?
Run-Time Check Failure #2 - Stack around the variable 'Alt' was corrupted.
also what is a stack overflow really and how are they caused and prevented?
Thanks.
Steve
Not all who wander are lost...
|
|
|
|
|
I do not know the answer to your first question.
stack overflow is when you run out of stack space in your process. They can be caused in a number of ways, but the reasons including calling a recursive function that recurses until there is no more stack space, a bad message loop is created and an endless number of function calls are created until there is no more stack space. Your stack pointer gets corrupted.
Why they are really bad is that each time you call a function, it creates a stack frame at the current stack pointer (SP). All of the stack variables that are created in your function are allocated on the stack as well as the parameters that are passed into the function. If you run out of stack space, then you lose the ability to make function calls and allocate stack varaibles.
|
|
|
|
|
Basically it is a new feature in VC7.
Let us say that Alt is a 10 byte character array. (char Alt [10]). If you write to the 11th byte, you will get this error.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Wow
That's indeed a cool feature.
Its amazing it wasnt there in VC 6.0.
We dont usually think of corrupted stacks.
Nish
Yeah that's me down below
|
|
|
|
|
There are 3 new debugging options that are nice. (But slow)
/RTCc - Checks for loss of precision. (i.e. char a = 10000)
/RTCs - Initialize local variables to non-zero. Detect over-runs and under-runs of arrays on the stack. Stack pointer verification (i.e. calling a __stdcall routine using __cdecl which has totally different stack requirements.)
/RTCu - Reports when a variable has been used prior to initialization. This is a run-time check and not compile time.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
C:\Windows\Desktop\Project3\Partition.cpp(178) : error C2440: 'type cast' : cannot convert from 'int (__thiscall Partition::*)(void)' to 'int'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast
int MemoryManager:: searchList(int pID)
{
LinkedList<partition>* current;
LinkedList<partition> first = Li.info();
current = &first;
Partition tempPartition = current->info();
while((current != NULL) && (((int)tempPartition.getProcessID) == (int)pID))
{
current = current->next();
}
return 0;
}
<\pre>
could anyone tell me how do i fix this thank you.
|
|
|
|
|
What's all this Partition stuff?
STL or something???
And which line is 178 here???
Nish
One Nish is trouble enough.
Imagine 16 of me, dancing wild...
:jig::jig::jig::jig:
:jig::jig::jig::jig:
:jig::jig::jig::jig:
:jig::jig::jig::jig:
|
|
|
|
|
int MemoryManager:: searchList(int pID){ LinkedList* current; LinkedList first = Li.info(); current = &first; Partition tempPartition = current->info(); while((current != NULL) && (((int)tempPartition.getProcessID) == (int)pID)) { current = current->next(); } return 0;}
<\pre>
the Partition class is a class that i defined myself.
|
|
|
|
|
Is this where you get the casting error :-
(((int)tempPartition.getProcessID)
If so what is getProcessID?
If it is a function that returns an int write it as getProcessID(). Because when you write it as getProcessID without the '(' and the ')' you are passing a pointer to the function
Nish
One Nish is trouble enough.
Imagine 16 of me, dancing wild...
:jig::jig::jig::jig:
:jig::jig::jig::jig:
:jig::jig::jig::jig:
:jig::jig::jig::jig:
|
|
|
|
|
Hi,
I have a question about multithread.
Let say there is an array called DBObject[100], and my thread function need access to this array. All threads are required to get a "permit" from the main function, so that this thread can have permission to access the particular data item in array.
Permission will be granted IF DBObject[i]= "free"
Let say:
Thread A: 1. Ask for permission to change DBObject[10] -> "X"
2. If permission receive ---- (DBObject[10]= "free"),
then change DBObject[10] -> "X"
3. Else, wait until DBObject[10]="free"
Thread B: 1. Ask for permission to change DBOject[10] -> "Y"
2. If permission receive ---- (DBObject[10]= "free"),
then change DBObject[10] -> "Y"
3. Else, wait until DBObject[10]="free"
(basically, they are using the same thread function.....)
My question is: Is it possible that both thread A and B can read the DBObject[10]="free" at the same time and therefore, think that they have permission to access DBObject[10] and change the DBOject[10] value at the same time. (if it's happened, then i don't know what will happen......)
p.s.: (the point (1), (2) and (3) are stored in a normal function (not thread), and those thread function just calls this function with some parameters);P
Please help!!!!!!!!!
|
|
|
|
|
You need to use thread synchronization objects.
I suggest a critical section here
Nish
One Nish is trouble enough.
Imagine 16 of me, dancing wild...
:jig::jig::jig::jig:
:jig::jig::jig::jig:
:jig::jig::jig::jig:
:jig::jig::jig::jig:
|
|
|
|
|
Critical section objects can be used only by the threads of a single process!
soptest
|
|
|
|
|
soptest wrote:
Critical section objects can be used only by the threads of a single process!
Critical sections are used when you dont need cross-process suncronization. Only one thread will be allowed access to it.
MSDN snip follows...
[snip]
An object of class CCriticalSection represents a “critical section” — a synchronization object that allows one thread at a time to access a resource or section of code. Critical sections are useful when only one thread at a time can be allowed to modify data or some other controlled resource. For example, adding nodes to a linked list is a process that should only be allowed by one thread at a time. By using a CCriticalSection object to control the linked list, only one thread at a time can gain access to the list.
[/snip]
Regards,
Nish
One Nish is trouble enough.
Imagine 16 of me, dancing wild...
:jig::jig::jig::jig:
:jig::jig::jig::jig:
:jig::jig::jig::jig:
:jig::jig::jig::jig:
|
|
|
|