|
Since you are not passing a pointer, a copy of the CStringArray is needed. If you derive a class from CStringArray, you can create a copy constructor to do this. An easier method would be to pass a pointer to a CStringArray, and not create a second CStringArray within the function.
|
|
|
|
|
I find it's better to pass in an object like this by reference as a parameter instead of returning a pointer. I usually return an error code instead.
As a rule, the standard collection of containers is a far better choice than the tinker toys that ship with MFC.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Christian Graus wrote:
As a rule, the standard collection of containers is a far better choice than the tinker toys that ship with MFC.
You never miss a chance, do you?
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
Alvaro Mendez wrote:
You never miss a chance, do you?
Not if I can help it, no. I've been too quiet on this forum for some time, and *someone* needs to make a stand for righteousness....
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
|
|
|
|
|
Preach it brother! Halleluya!
By the way, I went to a Christian church for the first time a couple of weeks ago and saw the preacher "healing" a bunch of cancer-ridden people. As he was chanting over each one of them, I noticed that several of them were fainting and falling backwards, just like on TV!
What is your explanation for this behavior?
Also, I was only there for about 30 minutes -- got there late -- and I swear I must have counted about 30 Halleluyas coming from the preacher. Overall, it was an interesting experience.
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
Alvaro Mendez wrote:
saw the preacher "healing" a bunch of cancer-ridden people.
Hmmm... According to the Bible, anyone can pray to God and expect to be healed. I know several people healed of cancer, including one who was prayed for when not a Christian and was converted as a result of being healed by God.
Alvaro Mendez wrote:
As he was chanting over each one of them, I noticed that several of them were fainting and falling backwards, just like on TV!
Urg.
Alvaro Mendez wrote:
What is your explanation for this behavior?
Groupthink ? Basically people fall over because they know it's expected of them/encouraged. The Bible has nothing to say about people falling over, it's part of the circus many 'modern' churches engage in. In fact, they call it being 'slain in the Spirit', the closest the Bible comes to referring to this is when God *KILLED* people in the Old Testament who opposed Him. The 'slain of the Spirit' in the Bible were dead, dead, dead.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
|
|
|
|
|
I spawn a modeless CDialog derived object from my MDI view class. When the user closes this CDailog with the system menu, I want to get rid of it totally.....
I did a new to create it in the View. If I put a delete this in the destructor of the cdialog is that enough? Also I created this object locally. Is there a problem with that and doing the delete? (if indeed the delete is legal..?)
Appreciate your help,
ns
|
|
|
|
|
Some points:
1. Putting "delete this" in the destructor will not work. If the destructor is being called it's because the object is already being destroyed. So if you try to destroy it again...
2. The proper way to get rid of modeless dialog boxes is with DestroyWindow. Call that inside your OnCancel or OnOK functions. Alternately, you can do a "delete this" instead, which will call DestroyWindow. However, "delete this" will blow up if the dialog box is not created with new every time, so be careful.
3. If the dialog is modeless, the user will be able to create more than one of it. If that's not OK with you, how do you prevent it?
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
urgh.....only one Cdialog to be created....I havent thought of it yet...maybe set some sort of flag?
I dont have an onOK or onCancel.....I just want the dlg dismissed with the system menu. So thats why I thought if I did delete this in OnClose() it might work? I didnt state this yet so what do you think about this idea?
you said" it will blow up..." why ?
Appreciate your help,
ns
|
|
|
|
|
Here's what I would do:
1. Use this code to create the dialog box:
static CMyDlg s_dlg;
if (!::IsWindow(s_dlg.m_hWnd))
s_dlg.Create(CMyDlg::IDD, this);
s_dlg.ShowWindow(SW_SHOWNORMAL);
2. Inside your OnClose, call DestroyWindow();
This ensures your dialog is created only once and that it's properly destroyed.
ns wrote:
you said" it will blow up..." why ?
Sorry, typo. I modified my post. I meant that it will blow up if you call delete this and the dialog is not created with new. It's because it will try to free memory from the heap which wasn't allocated on the heap to begin with.
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
Many thanks!
Quick question:
I've got three (actually decided at run time) buttons on my project and each will spawn a CDialog. If I use the same variable s_dlg is it okay? (No static right? )THe only things i will do with these CDlgs is a. close them, or b.resize them. So in the OnClose, with your strategy, will the code know which window to destroy? SInce now s_dlg is only pointing to the last CDlg created....
Appreciate your help,
ns
|
|
|
|
|
Well, if it's 3 separate dialog boxes, I recommend you create 3 separate methods, each with its own static object:
void CMyView::OnButton1()
{
static CMyDlg s_dlg;
s_dlg.Create(this);
}
void CMyView::OnButton2()
{
static CMyDlg s_dlg;
s_dlg.Create(this);
}
void CMyView::OnButton3()
{
static CMyDlg s_dlg;
s_dlg.Create(this);
}
Then you can add this method to your dialog class:
void CMyDlg::Create(CWnd* pParentWnd)
{
if (!::IsWindow(m_hWnd))
CDialog::Create(IDD, pParentWnd);
ShowWindow(SW_SHOWNORMAL);
}
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
|
Great article! Also need to know ....this CDialog is merely informational. So I dont refresh it (may resize it), so is it better to use a local variable or a member variable? I can easily push the pointers onto a vector, so thats not a problem....I just dont knoew if its necessary> Can I use the info in the article in the event that I create a local variable each time the button is pressed to spawn a new dlg?
Appreciate your help,
ns
what I have are a set of cdlgs which in turn send messagse to the view when their button is pressed, wehich spawns the other CDlg. SO yes I can have many CDlgs - thats okay, but only one for each original CDlg which sent the message (the one with buttons)
|
|
|
|
|
One solution is to declare a pointer to the dialog box as one of view's private members.
Inside OnClose(), call DestroyWindow(). Inside PostNcDestroy(), call
CDialog::PostNcDestroy() and delete the object via "delete this." Post a message to the view class and set the pointer to NULL.
Kuphryn
|
|
|
|
|
Put the "delete this" into the PostNcDestroy handler of your dialog.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I might work if you put on WM_DESTROY. If you put in the destructor it will never be called at best, or called recursively on the deleted object(read undefined).
|
|
|
|
|
I am drawing some figures and storing these figures as bmp file. All of this drawing is
done on a window that is not shown to the user.
This is done by using
memDC.CreateCompatibleDC(NULL);
bitmap.CreateCompatibleBitmap(&memDC, 600,400);
Now this memDC is used for drawing diffrent figures.
as memDC.Rectangle(---);
I use diffrent color of Pens to draw figures.
It works fine in normal case but in mine case when diffrent colors of pens are selected
only black color is displayed for all figures.
Help me so that using
memDC i can create figures generated by diffrent color of pens.
I hope this has clarified you.
Thanks.
|
|
|
|
|
try using NULL as the DC for your CreateCompatibleBitmap. when you use the memDC, you'll always get black & white.
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
I'm using directdraw, and I got a problem.
I'm making a pong game, and I don't know
how to change the color of the rectangels
that the game is going to be build at.
Without ddraw, I'm doing that:
HDC hdc;
HPEN hPen;
HBRUSH hBrush;
hPen = GetPen (PS_SOLID, NULL, RGB(0,255,0));
hBrush = GetSolidBrush (RGB(0,0,0));
PAINTSTRUCT ps;
BeginPaint (hdc, &ps);
Rectangle (hdc, 23,54,100,249);
EndPaint ();
(I don't think the code is totally correct)
And it works!
When using ddraw, I'm writing something like this:
HDC hdc;
lpDDSBack->GetDC (&hdc);
Rectangle (hdc, 23,54,100,249);
lpDDSBack->ReleaseDC (hdc);
lpDDSPrimary->Flip (0, DDFLIP_WAIT);
WHERE IN THE H*LL DOES I PUT THE COLORS????
please, help me!!!
My english is bad?
Who cares!
|
|
|
|
|
I am editing a customer's code. It has a dialog with some buttons on it. IDOK and IDCANCEL are not present. I would like to select one of the buttons to be activated like a single button click. After the button has been activated, I would like to move the default button to another button. The tab stop is selected on each button, but tab does not bring up a focus.
TIA
Steve
|
|
|
|
|
I'm not sure what you need exactly, but it seems like you want to set the focus on a button. For that, SetFocus() should do the trick.
If you still need help, please post some code or try explaining the problem again.
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
One solution is to set the current default button. Here is an example.
-----
DWORD style = m_BtnA.GetStyle();
// Make sure ButtonA is not already the default button
if ((style & BS_DEFPUSHBUTTON) != 1)
{
// Get style of ButtonB
style = m_BtnB.GetStyle();
// Remove default push button style
style &= ~BS_DEFPUSHBUTTON;
// Set the style of ButtonB
::SendMessage(m_BtnB.GetSafeHwnd(), BM_SETSTYLE, (WPARAM)style, (LPARAM)TRUE);
// Inform the dialog about the new default control ID
SendMessage(DM_SETDEFID, m_BtnA.GetDlgCtrlID());
// Get the style of ButtonA
style = m_BtnA.GetStyle();
// add the default push button style
style |= BS_DEFPUSHBUTTON;
// set the style
::SendMessage(m_BtnA.GetSafeHwnd(), BM_SETSTYLE, (WPARAM)style, (LPARAM)TRUE);
-----
Kuphryn
|
|
|
|
|
Thanks for the suggestions. They will be very helpful for the next part of what I want to do once I solve the main problem. Upon further examination, I find that this is an MDI problem.
The MDI child window is being opened. The buttons I want to access are in the child window.
Upon opening of the child, hitting TAB or ENTER has no effect. If I click the buttons with the mouse, I now have TAB and ENTER control thoughout.
I can trap keystrokes in MainFrame. So the Mainframe seems to have the focus for keyboard input.
The big question:
How, once I have made the Child window, can I place the default focus inside of that window so that keystrokes are sent to the child windows controls?
Steve Stiller
|
|
|
|
|
I want to write a program to delete the everyone group from a machine. I have no ideal of what header I should use, the name of the function, and the sentax please help
|
|
|
|
|