|
|
Thank you, but not exactly what im trying to do. I want to be able to move the child around inside of the parrent, i guess turning my parrent into a sort of MDI Dialog box. But yeah, i want to be able to move the dialog box around, close it...ect
thank you
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
There's a fair bit of work ahead of you then, unless you just use the existing MFC or WTL MDI classes (i would strongly suggest doing this). Regardless, that's the place to look for information - both MFC and WTL come with full source code, and the MDI stuff is reasonably clear.
How do you move in a world of fog, That's always changing things?
Makes me wish that i could be a dog, When i see the price that you pay.
|
|
|
|
|
Would anybody like to help me to produce a random number for my C++ guessing game?
|
|
|
|
|
Sure. Here's one: 6410086356. Or you could use rand() and srand() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
If you are content with pseudo-random numbers, use rand() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
srand((unsigned) time(NULL));
this is what I use to "seed" the random number generator. Otherwise the numbers won't be so random.
number=(rand()%6)+1;
this picks a random number 1-6. (0-5 until you get to the +1).
|
|
|
|
|
Would anybody like to help me to produce a random number for my C++ guessing game?
|
|
|
|
|
I wrote a DLL in C++ that I am testing by calling it from VB. the dll works and does what it's supposed to do, but when I end the running vb demo, I get a heap memory error. any idea what's up?
thank you.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
The DLL is not cleaning up after its' self. Or the demo program is not calling the functions in the DLL that are reasponsible for cleaning up.
INTP
|
|
|
|
|
there is only one function in the dll, so it must be me not cleaning up after myself. Can you give me any hints on how to go about doing this?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Since you wrote the DLL your self then you need to see where you are allocating memory and make sure it is released either when the DLL is unloaded or before the function call returns.
If the allocated memory block is what is being returned then you should probably provide a second function in your DLL used to release it after you are finished using it.
In C/C++ the calls may look something like this:
BYTE* pData = GetData(arguments);
ReleaseData(pData);
In VB it may look like this:
VARIANT data
data = GetData arguments
ReleaseData data
Using Get and Release functions is a versatile pattern, as it may allow for data hiding. An example of the is GetDC and ReleaseDC, where a handle is retreived and then released after you are finish using it. You do not need to know if the handle is a simple index value or a memory pointer, all you need to know is what functions to call in order to use it.
INTP
|
|
|
|
|
I made sure that I released all variables that were allocated on the heap. But just to see how far I get, I put a frivolous return in the dll in a certain space, and now it works fine. But if I move it down a few lines, I get that error again. Here's an example:
sColumns = sColumns.Left(sColumns.GetLength() - 1);
sColumns = "CREATE TABLE " + strTblName + " (" + sColumns + ")";
pDB.ExecuteSQL(sColumns);
<-- Works fine if I put it on this line
CDBFRecordset m_Set;
return 1;
I'm guessing it has something to do with this class (CDBFRecordset) because even if I put the return before this object variable it compiles without warnings. If I put it in the bottom position I get warnings like this:
warning LNK4098: defaultlib "mfcs42d.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
do you have any idea what's wrong?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
The error message means exactly what is says, type LNK4098 as the index in MSDN library for an expanation. The only reason I can think of why moving the return statment stoped the warning message, is that the complier upon seeing an early return statement probably proceded to ignore (not compile) the code following (with in the function) that statement and therefore did not find the problem. When you compile you code set the warning level to 4, that may cause it to generate an unreachable code warning, which suggest that it may not bother looking at that part of the code for errors.
There is also the possibility that the debug version of the library is conflicting with the non-debug version of the libaray. I may be mistaken but the 'd' at the end of the library name indicates that it is the debug version, if that is the case it may conflicking with the non-debug version (probably mfcs42.lib). You might want to check your project settings to see if you are linking to the correct libraries.
The article LNK4098 will tell you how to determine which libraries you are linking to.
INTP
|
|
|
|
|
Hi
In windows 2000 or any other operating system when we right click on MYComputer on desktop and see the general properties we see one OEM number. Like "Registered to some company name ansd a number like 56789-OEM-99456-5355
Can any body suggest me how to get this number through Programming in VC++ 6.0. I tried GetsystemInfo with dwOemID but it is giving me 0.
Thanks
Shailesh
|
|
|
|
|
Try the following registry value:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I got this odd problem today (well, one of my testers got it):
I got a function that returns a pointer to my main window, casted to the correct type. It looks something like this:
CMyMainWnd* _GetMainWnd()
{
return dynamic_cast<cmymainwnd*>(AfxGetMainWnd());
}
The strange thing is that this fails at one point. I first thought that it was due to the function being called from the wrong thread, but that wasn't the case. I took a look at what AfxGetMainWnd() returned, and it was the correct window (at least the title was correct; I never had this problem, so I can't debug it). The window title clearly states that this is "CMyMainWnd", but the dynamic cast still fails and returns 0.
What could cause this problem?
Maybe I should just use a stupid cast and cross my fingers
|
|
|
|
|
It looks like AfxGetMainWnd() will return NULL if it is called from a non-GUI thread. ie. A Worker thread. Or of course if the main window in a GUI thread is not of type CMyMainWnd or derived from it.
Simple enough to test what AfxGetMainWnd() returns and ASSERT or log errors.
BTW. We can't see you <cast_type> You need to use the < and > and pre and code Formatting Toolbar options when embedding code in posts.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
No, AfxGetMainWnd() does not return NULL. How else could I get the Window caption?
The thing is that the caption is correct, just the caption of the main window as it should be. So, I assume that AfxGetMainWnd() returns the correct window pointer, but the cast just fails.
And thanks for the hint on the < and >... I will keep that in mind next time.
|
|
|
|
|
Neville Franks wrote:
BTW. We can't see you <cast_type> You need to use the < and > and pre and code Formatting Toolbar options when embedding code in posts.
It looks like it is:
return dynamic_cast<CMyMainWnd*>(AfxGetMainWnd());
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
why dynamic_cast and not static_cast?
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
You'd have to ask Tak that one. I was simply helping Neville see potentially hidden text.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I have an ATL com dll and i want to get a function from it. The question is what is the syntax.
Lets say the name of my dll is: Test and the name of my function is getName ?.
|
|
|
|
|
The syntax... the syntax of what?
The syntax of the function? Do you mean the function prototype, do you need to know the function's prototype?
Or perhaps you want to know how to go about calling that function.
Please clarify.
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|