|
I tried adding a static variable inside a class. ie static CButton m_button and I get a linker error. Any ideas.
Thanks
|
|
|
|
|
If you add a variable as a static it is declared, but not defined. You need this:
class a
{
static int i;
}
int a::i = 0;
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Hello,
I am having trouble with FindResource() when trying to find a resource of custom type.
This code returns null:
<br />
HRSRC hResource = ::FindResource(hInst, "IDR_MYNAME", "MYTYPE");<br />
I also tried FindResourceEx with my language locale, but all the same.
Any ideas as to what I am doing wrong?
|
|
|
|
|
I presume that IDR_MYNAME is your resource ID - in which case you want:
HRSRC hResource = ::FindResource( hInst, MAKEINTRESOURCE(IDR_MYNAME), "MYTYPE" );
Dave
|
|
|
|
|
Yes, I am sorry about that , this is what I've been using.
It doesn't work.
While this works:
<br />
HRSRC hResource = ::FindResource( hInst, MAKEINTRESOURCE(IDB_MYBITMAP), RT_BITMAP); <br />
|
|
|
|
|
Maybe your resource is not in the instance handle passed.
Maybe your resource 'type' did not get stored as "MYTYPE".
Open the DLL or EXE with Visual Studio in 'as resource' mode to see if the resource is really in there.
You might check the value of GetLastError, it usually helps track it down the problem.
C++/MFC/InstallShield since 1993
|
|
|
|
|
hi there, i'm new to this place and Visual C++, so bear with me if i don't ask this clearly....
basically...
i have an SDI based on the form type (so effectively it's a dialog with saving).
I have a tree structure forming, where each node will represent a different version of a file. What i want to do is drag a file, or open a dialog or whatever and add the details to this tree.
I think i know how to store the details, serializing classes and things, it's just getting the information for the file. Preferably i would want to copy the file to it's own subdirectory too...
so to summarise I'd like the following but am unsure on file handling.
NOTE: I'm not talking the file handling as in saving the SDI... i mean dragging a file into the dialog.
The tree would look something like this:
test.txt-
|-Version 1.0
|-Version 1.1
|-Version 1.2
The node would point to an object which needs to contain the file location and other attributes.
For simpleness the file location would be a subdirectory called "version 1.x" from where the SDI document is located...
Hope i'm not asking too much
Just a few pointers on this kind of file handling would be great - i'm not neccaserily asking for a complete solution
Thanks very Much
Colin Davidson
|
|
|
|
|
One solution is CFile. Another solution is CStdioFile.
Kuphryn
|
|
|
|
|
I need to update the resource in an exe file under Windows 98 when my program is running. Under Windows 2000/XP, I can use BeginUpdateResource, UpdateResource and EndUpdateResource. But I am dejected that these functions don't exist under Windows 98. What can I do? Please help.
stanley
|
|
|
|
|
As far as i know, you cannot do this under Win95/98/ME unless you directly edit the PE file format (which is not pretty...).
Dave
|
|
|
|
|
Can you give me a sample including source codes under win95/98/ME?
stanley
|
|
|
|
|
Unfortunately not - i investigated a bit a while ago, but decided it wasn't worth it because most of our users are on NT/2K/XP. So that functionality is just not available under Win95/98/ME.
Dave
|
|
|
|
|
Oh, my god! I am so unlucky! Because of my client's request I have to realize the funtionality. I need help really. Please....
stanley
|
|
|
|
|
Is it possible to post a message to a CDocument derived class? I am curious because I noticed that it has a BEGIN_MESSAGE_MAP()/END_MESSAGE_MAP().
Plus it would be really handy if I could have a thread post a message to the document so that it is updated. I know I can do this if I post a message to a CView, but I would like to do it to the document then have the document update the views using something like UpdateAllViews().
Cheers,
Clint
|
|
|
|
|
A document is not a window, so you cannot post arbitrary messages to it. You can send WM_COMMAND messages to it, but only because MFC handles the message routing itself. CDocument is derived from CCmdTarget , which means "can be the target of a WM_COMMAND message"
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
BUY MY SOFTWARE!! (please?) RightClick-Encrypt | 1ClickPicGrabber
My IntarWeb Homepgae!!!11
|
|
|
|
|
Thank you for the clarification.
Perhaps you could answer another question. I have a thread that is owned by the CDocument derived class. The threads sole purpose is to wait on some incomming data then update a structure in the document. The problem I was running into is that when I called UpdateAllViews I would ASSERT() because of some issues with multithreaded programs and c++ objects.
I thought then that I could just update the data, then post a message to the document which in turn calls UpdateAllViews . That way there wouldn't be a problem.
Any suggestions?
Cheers,
Clint
|
|
|
|
|
Why don't you just post a message to the MainFrame and then use GetActiveDocument()->UpdateAllViews(...)?
Also use (CDocumentClassName *)GetActiveDocument()->SpecialProcessingFunctions(..) in the MainFrame to do any document manipulations which can also be message or timer driven.
Steve
|
|
|
|
|
This way it goes more Frame/Doc/View architecture than the pure Doc/View. I would personally avoid coding logic in the frame window unless it's absolutely needed (which is not the case). The message map in CDocument class can be nicely utilized to handle menu/toolbar/accelerator messages that are related to the document. Try to create message handlers in the classes that own the variables you use in these handlers, so there is nothing like ((CDocumentClassName *)CFrameWnd::GetActiveDocument())->SpecialProcessingFunctions(..) , but rather CDocumentClassName::OnSpecial() .
Regards,
BB
|
|
|
|
|
Someone please tell me what classes and DLLs do. Thanks.
|
|
|
|
|
A DLL is a compiled "executable" (not directly) exporting function that one or more applications may call. Since applications are sharing DLLs, if you change a function in the DLL, all the applications will "change" if they call the modified function.
A class is a structure containing function and member variables, who may by instanciated one or more times in objects. To understand the difference between classes and objects, try to remember this comparaison with cook : the class is used to make cakes, objets are cakes.
Then, imagine your class have a function called EatPie() and you have instanciated 3 objects. For each object, you may call EatPie() and potentially decrease a counter counting the number of pie of each cakes.
Since I can't spend more time to explain you classes and DLL, I recommend you to read books or parse the Web about infos.
Cheers,
Florian
|
|
|
|
|
classes are where you go to learn things, like what a DLL does.
|
|
|
|
|
|
hahaha real funny u make it obvious that you dont know either
|
|
|
|
|
Anonymous wrote:
classes are where you go to learn things, like what a DLL does.
|
|
|
|
|
CLASS:
---------------------------------
DEFINITION:
declaration of an object.
EXPLANATION:
Imagine a button, a button has a color, a text and an icon (all those parameters are member variables of the button class).
A button also have a function that is called when the button is pressed (a member function).
SAMPLE:
class cbtn
{
private:
COLORREF m_clrColor;
CString m_csText;
CIcon m_Icon;
void OnClick();
};
Once you have the class declared, you can instantiate (define - create objects of) that class so many times...
DLL:
---------------------------------
DEFINITION:
executable that exports functions and variables to other executables.
EXPLANATION:
You can build dll's or use other dll's that are installed in your computer, those programs can be used from any program that knows how to call their functions or variables...
imagine that you create always a program that (it's just an explanation and the sample will be very stupid) add two numbers and the code to do so is very long (I adviced you that that would be stupid...) then you could consider to place that code in a DLL and call that code from your programs...
FINALLY
---------------------------------
To go to class to learn is interesting if you can't do it, think of reading a good C++ book for learning about classes and another Windows programming book for DLL's...
Hope this helps...
PS:
the samples are just introductory and they have my point of view, they are not the purest and best ones, but they can help you to get the starting point when reading some info regarding this.
NOTE:
my english is not my best.
Hope this helps...
|
|
|
|