|
There is no class here, only a namespace. You just said they were globals, didn't you ? You can call new in the .cpp file. You could also assign to NULL, and have your classes call new if NULL.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Thanks for the reply.
I will try it out.
Thanks a million!
|
|
|
|
|
do your "new" in your CWinApp's InitInstance.
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
Declare a class in global.cpp and make a single instance of that class
class CGlobal
{
private:
CGlobal()
{
myptr = new int[32];
}
~CGlobal()
{
delete [] myptr;
}
};
static CGlobal globalInit;
oRion wrote:
If the new() statement is implemented in the constructor, would this means every class derive from this Base Class, would call new() statement in the constructor? This means redudant memory allocation is done here?
Yes. Just don't derive from the class. That can be prevented by making the constructor private.
The other option is to make a GlobalInit() and GlobalCleanup() function which does your allocations and call it at the beginning of your program.
Todd Smith
|
|
|
|
|
Todd Smith wrote:
Declare a class in global.cpp and make a single instance of that class
class CGlobal{private: CGlobal() { myptr = new int[32]; } ~CGlobal() { delete [] myptr; }};static CGlobal globalInit;
Thanks for the reply. I understand the portion on using private for constructor. Could u help tell me more of the statement on
static CGlobal globalInit; ? Where should this be declared in?
Why is there a need to declare it as a static ?
|
|
|
|
|
Hi there,
I have a paradox database ...
I want to open this database by ADO ...
Can i open this database by ODBC driver ?
If yes, i must update my MDAC, is it right ?
I already download MDAC 2.7, can i work with that for opening paradox ?
Please help me !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
If I create an application and use an Access database and a user installs my app on their computer without Access installed, will my application still work...?
Basically is the Access driver a DLL which I can distrubute with my own applications...???
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
To use .mdb databases without Access installed, you'll need so called Jet Engine. It was distributed as part of MDAC stack, but was dropped around MDAC version 2.6. Now you'll need so called Jet 4.0 SP3. Check this MS site for download link:
www.microsoft.com/data[^]
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Thanx i'll check it out...
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I have a check box button that I create as child of another window at run time. I could not make the checkbox as big as the its window text. it is always bigger that the text. How can I make the check box fit to its text ?
The code I am using is below.
void CParentWindow::PreSubclassWindow()
{
CRect Rect;
GetWindowRect(&Rect);
ScreenToClient(&Rect);
CDC * dc = this->GetDC();
CSize size = dc->GetTextExtent(strCheckBoxCaption);
//Create the check box rectangle
CRect CheckRect (Rect.left + 5, Rect.top , Rect.left + size.cx,
Rect.top + size.cy);
m_Check.Create(strCaption,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_CHECKBOX,
CheckRect,this, 1);
}
Christian Grauss has an article that creates a check box in a static window. But his check box is also bigger than its text.So I could not find an example. How can I fix this ?
Thank you
Orcun Colak
|
|
|
|
|
You want the box and the text to be the same height ? By changing the height of the checkbox ? If you do that, your checkboxes will look different from all the others, for no good reason I can see. Given how simple checkbox functionality is, you could roll your own, but there may be some benefit in some architectures in deriving it from the existing one all the same.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Hi
I just followed the instructions of Erik Thompson's article on how to create deskbands (such like toolbars in InternetExporer or on the taskbar itself).
Ok, everything went fine so far, I could compile my deskband.
By rightclicking on the taskbar I added my deskband to the taskbar. It showed up properly
Now I removed my deskband again because I had to recompile my DLL due to some changes.
But I can't compile it anymore because the file is in use now by the Explorer. However, I removed my bar from the taskbar
So how the hell can I compile my project now?
thanks in advance
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
try to reboot, or kill explorer and re-execute it
and then recompile it.
|
|
|
|
|
Come on, there must be a nicer way to accomplish this. I don't want to reboot before every new compile
modified 12-Sep-18 21:01pm.
|
|
|
|
|
well,
there r some programs that check
what process is keeping a reference
to your dll, and they will kill it.
i am not sure but i think there's an
article somehwere in this site that
explains how to debug shell extension
without killing the process. try looking
out for it.
|
|
|
|
|
and i also want to add to it that
i think there is a registry key
that tells explorer to completly
unload a dll after using it, however
i'm not sure what is it. u should try
looking it up in MSDN!
|
|
|
|
|
Rebooting works.
Or, have Task Manager running (if in NT/2k/xp) and kill all explorer.exe processes. Then start a new one (from the "File|Run" command).
The last Explorer.exe is using your DLL, so when you kill it, the DLL is no longer in use. But, when this process is ended, you Start taskbar will disappear, so you need to have Task Manager running to be able to restart Explorer.
|
|
|
|
|
And for anyone who gets stuck in the "Explorer is dead and my task manager isn't visible" mode, you can always hit Ctrl+Shift+Esc to launch the task manager.
Chris Richardson
|
|
|
|
|
I started to design the visual shell for my application, that is I have made several dialog windows and populated them with the required list, combo, button and labels etc...
I now have to code this application and am having trouble getting the buttons to open up the dialog windows that I made earlier. *See thread below (buttons)*
1. void CSkydiveDlg::OnCarear()
2. {
3. CMyDialog MyDialog(); // this is the 2nd dialog
4. MyDialog.Create(..parameters if needed); // create it
5. MyDialog.ShowWindow(true); // then show it
6. }
As I understand it on line 1. it's saying that when the Carear button is activated do whats in the braces. (what exactly does CSkydiveDlg:: do?)
Could someone explain line 3 to me. Where do I get the CMyDialog from, or should it be CDialog.... and is MyDialog(); any name I can make up to suit my purpose ?
On line 4. MyDialog (name created on earlier line ??) is then telling the machine to create something ?? What is it creating ?? Another Dialog window ?
Line 5. I hope I understand... It's just saying that MyDialog should now actually show it's window on the screen.
What have I screwed up that won't let my code work the button ?
Pleaseeeeeee some one heeeeeelp........
Would be really good if someone could send a tiny working program with two dialog windows, a button in the first which opens the second and closes the first.
blairstent@hotmail.com
Cheers.
P.S. If you're not living life on the edge you're taking up too much room.
From Crazy Skydiver.
|
|
|
|
|
if this is a plain old, everyday modal dialog (one that takes over the app until the dialog is closed), you don't need to use Create. just create it (line 3) and call MyDialog.DoModal(); .
if you're creating a modeless dialog then the process is much different, and you should probably check out any of the modeless dialog articles on this site.
WWJD? JWRTFM. found on /.
|
|
|
|
|
In a CP article I'm folowing, he has in the dbImages.h file (a class derived from CRecordSet)
the following:
class CdbImages : public CRecordset
{
public:
CdbImages(CDatabase* pDatabase = NULL);
DECLARE_DYNAMIC(CdbImages)
CString m_BLOBName;
CLongBinary m_BLOBImage;
What do I need to do to get the wizard to automatically put the entries in the afx_field above? Or is this put in by hand?
The article I'm referring to is at http://www.codeproject.com/database/usingblob.asp
Thanks,
ns
|
|
|
|
|
NE1 know how to get CButtonST to display muli lines on a button? I would also like to display other chars like the right arrow.
Thanks!
|
|
|
|
|
you might get a better response if you ask this question on the CButtonST page.
but, as a starting point for multi-line text, you might try finding the place where the text is drawn and add the DT_MULTILINE style to the DrawText command - just to see what happens.
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
can anyone tell me how can i disable the
combination of alt+f4 on another window
which i have its window handle (without hooking
to its window procedure)?
thanks
|
|
|
|
|
You can't do that.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|