|
See the answer from Rage.
Another thing, you are doing one new , but no delete , and that causes memory leaks.
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
you new the dialog in the function
and delete it in this funtion too
so you can not see the dialog
|
|
|
|
|
Rage gave you a great response, but let me just add my personal solution:
Like Rage said, the modeless dialog dissapears because you're probably creating the class as a local variable.... so, to kill 2 birds with one stone, the solution is simple: create the class as a static variable!
static CMyDialog s_dlg;
if (::IsWindow(s_dlg.m_hWnd))
s_dlg.ShowWindow(SW_SHOWNORMAL);
else
s_dlg.Create(CMyDialog::IDD);
This keeps your dialog class around and also ensures that only one is created.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
i am trying to findout if there are a Line Class in MFC.
for example in a Specified Device Context i want to define a Line Object with 2 attributes
1. Source-Cpoint
2. Destination-Cpoint
if i change the Source-CPoint of a Line Object in a DC then Line changes in that DC.
|
|
|
|
|
There is no actual line object per se in MFC, but as it is just two points, its not difficult to
roll one yourself.
You could either make a new class / struct with two point members:
struct CLine
{
CPoint ptStart;
CPoint ptFinish;
void DrawLine (CDC *pDC)
{
pDC->MoveTo (ptStart);
pDC->LineTo (ptFinish);
}
};
Or just use a CRect to store your coordinates, and use .TopRight () as one end, and BottomRight () as the
other, which is what I do.
Most of the time I want to draw a bunch of lines, so PolyPolyLine is superior anyway even if is not included
in CDC...
Iain.
|
|
|
|
|
Why not
class CShape {
public:
virtual void Draw(CDC* pDC) const = 0;
virtual ~CShape();
};
class CLine : public CShape {
public:
CPoint ptStart;
CPoint ptFinish;
CLine(const CPoint& ps, const CPoint& pf) : ptStart(ps), ptFinish(pf) { }
void Draw(CDC *pDC) const {
pDC->MoveTo (ptStart);
pDC->LineTo (ptFinish);
}
};
Then you can start adding other shapes to your system.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
I run my VC on a Simplify Chinese Windows 98 . The font which could be selected of the VC editor is limit, only 5 types can be selected. I know it is different from the English Version of Windows. So I want to know how to make more font selections. Do I need to modify the registery table? Thanks!
|
|
|
|
|
Hi,
I have written this to draw the edge.
DrawEdge(pDC->m_hDC, &rect, BDR_SUNKENINNER , BF_BOTTOMRIGHT | BF_ADJUST);
Now i want to cahnge the edge color ,How can i do that?
|
|
|
|
|
I have some messages that are dispalyed in my application (error messages, welcome messages).
I was wodering what is the best way to define those strings:
1. in a resource file, or
2. define my own const CString object in a common header file.
I would like to hear your pros and cons on both options.
Thanks!
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
If you ever think of doing something like localisation, resources are the way to go (probably even a resource DLL).
But if you are happy with one (or maybe very few, with different binaries) languages, you can probably stay with const strings in your application.
Both are Unicode-ready, but when you choose english as your applications language, you will probably not need this.
Just my 2 Euro-cents
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
i have searched all over the MSDN to find a Function to chand this attribute
is there and Class Member of CWnd that can change the BackGround (of ForeGround )Color or Text Color.
tnx
Fight with the Best
Die like the Rest
|
|
|
|
|
To draw on a Windows pane, you need a windows device context (DC), which with MFC comes wrapped up in a CDC class. If you look in MSDN for CDC, you will find all sorts of drawing stuff.
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
i want to know how i can Draw a bitmap on a Window.
when i make a window and draw a Bitmap on it the window is still at top and my bitmap goes under the window:
cw=new CWnd;
cw->Create(_T("STATIC"), "99",WS_VISIBLE |WS_THICKFRAME ,CRect(0, 0, 20,20), this, 0xffff);
.
.
.
pDC->BitBlt(point.x-10,point.y-10,bm.bmWidth,bm.bmHeight,dc,0,0,SRCAND);
whats wrong ?
if anybody has a suggestion for attach a BitMap to a Window plz tell me.
|
|
|
|
|
Well, for starters, you're SRCANDing the bitmap over the window, I think SRCCOPY might be what you want, but I cannot remember, to be honest. Second, where are you drawing this ? It should be in OnEraseBackground.
How do you know it goes under the Window, surely the Window would cover it if it did ?
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
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
This makes me me crazy!
Tell me the C functions that can help me to separete the extension of a string like myfile.jpg .
thus, I only want the .jpg to be left.
And again, just tell me what C functions that perhaps help me with this. I want to build the code myself because this is a pretty much simple thing. I don't want sample code
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Why do you want C, as opposed to C++ ? In C, I'd probably just step back a char at a time, so use strlen to find out how long the string is, and step backwards.
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
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
Why do you want C, as opposed to C++ ?
What you actually is saying is: Use std::string instead!
right?
I never learn to use that!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
I never learn to use that!
So now's your chance.
But I seriously thought when you said C, you meant C. What else would I think ?
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
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
What else would I think ?
You would think C!
I will update my socket class library to usec std::string instead of char* to make it more objectoriented.
Mary christmas every one!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
_splitpath ?
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
using namespace std;
string string strExtension;
string strFileName = "myfile.jpg";
size_t nLastDotIndex = strFileName.find_last_of('.');
if(npos == nLastDotIndex)
cout << "Error! No extension" << endl;
else
strExtension = strFileName.substr(nLastDotIndex + 1);
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
I agree, use _splitpath. You may not want it, but it will give you the drive, dir, filename, and ext. It is only one line of code...
|
|
|
|
|
hi guys, I want to be able to detect mouse click on the desktop(not just any particular application window) , how do I do that? any sample code/suggestion is appreciated
|
|
|
|
|
SetWindowsHookEx() with WH_MOUSE is probably what you want.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
would you elaborate on it a little? sorry I'm a bit new to windows programming
thanks
|
|
|
|