|
Check this out.
http://www.paintlib.de/paintlib/
|
|
|
|
|
When i use class wizard to create a class delivered from CCmdTarget and support automation, the wizard defines constructor/destructor as protected.
(I think this has something to do with dynamic construction or something)
This doesn't allow me to create any instance of that class.
So, i just makes the constructor/destructor public and everything
works allright!
Is this a known bug of the wizard,
or i must create those classes in a special way?
What kind of problems can my aproach cause, if any?
- - - - - - - - - - - - - - - - - -
Memory leaks is the price we pay \0
01234567890123456789012345678901234
|
|
|
|
|
The guys at Redmond just assumed you'd only want to create a class their way I guess. I use (non-automation) CCmdTarget classes all the time and make exactly the same modification you have done.
Andy Metcalfe - Sonardyne International Ltd (andy.metcalfe@lineone.net) http://www.resorg.co.uk
"I used to be a medieval re-enactor, but I'm (nearly) alright now..."
|
|
|
|
|
I made a tempalte class,like
template <class t="">
class A
{
A();
~A();
}
template<class t=""> A<t>:: A(){};
tempalte<class t=""> ~A<>:: ~A(){};
double click on the function in ClassView Window,I can not goto the definition of the function,
Why?
|
|
|
|
|
does anyone know how to store hexadecimal numbers? cwhich data types can store hex numbers in the form 0xffff1234 and let the compiler readily read it as a hex number and not as a string. is dword such a data type?
|
|
|
|
|
There's no difference between hexadecimal and decimal numbers at all (for a compiler). Store it as a DWORD or a unsigned int and uses formatting functions or streams with hex manipulator when you need a textual representations of the number.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
I have a modal dialog box with a button with the function CMyDialog::OnMyButton() hooked to it.
Is it possible to show the dialog box (DoModal) and immediately start the function OnMyButton without wait for the user that press the button ?
|
|
|
|
|
Yes, and its easy too!
Just override OnInitDialog() in you class and call it from there. You'll have to call the base class implementation first to make sure everything's initialised:
BOOL CSomeDlg::OnInitDialog(void)
{
CDialog::OnInitDialog();
OnMyButton();
return TRUE; // Always return TRUE unless you set the focus to a control
}
Andy Metcalfe - Sonardyne International Ltd (andy.metcalfe@lineone.net) http://www.resorg.co.uk
"I used to be a medieval re-enactor, but I'm (nearly) alright now..."
|
|
|
|
|
Yes it's ok, but in this way the function OnMyButton goes in execution before the visualisation of the dialog box.
I want that the function goes in execution just after the visualisation of the dialog box, because inside it there are some partial result to show in the dialog box.
I tried with OnShowWindow but even this goes in execution before before the visualisation.
Thanks in advance Paolo
|
|
|
|
|
Ok, I didn't realise that. There's probably an override you could hook to do what you want here, but I can't think what it could be.
You could try posting a command message to the dialog from OnInitDialog():
CMyDlg::OnInitDialog(void)
{
CDialog::OnInitDialog();
PostMessage(WM_COMMAND, IDC_MYBUTTON, 0);
return TRUE;
}
If you do this, your OnMyButton() handler will be called as if you'd pressed the button yourself. The message will be queued and so will not be processed until the messages before it have been handled - which should include showing and painting the window.
Good Luck.
Andy Metcalfe - Sonardyne International Ltd (andy.metcalfe@lineone.net) http://www.resorg.co.uk
"I used to be a medieval re-enactor, but I'm (nearly) alright now..."
|
|
|
|
|
Great.
It works like I want.
Thanks a lot.
Paolo
|
|
|
|
|
Hi,
You could also use timer.
In the OnInitDialog()
SetTimer(1, 250, NULL);
In the OnTimer()
KillTimer(1);
//Your code
This have worked for me.
|
|
|
|
|
1. How could I move data from a "CString" variable to a "C++ standard string class" variable?
2. How could I move data from a "C++ standard string class" variable to a "CString" variable?
Thanks in advance.
|
|
|
|
|
look into the strcpy function
eg:
char* dest[1024];
CString sSource = "testline";
strcpy(dest, sSource);
|
|
|
|
|
I think this should help (I didn't check)
CString strMfc;
string strStl;
strMfc = "Aaaa";
strStl = strMfc; //1st assignment -> simple
strStl = "Bbbbb";
strMfc = strStl.c_str(); //2nd assignment -> use c_str() for char * conversion
Miroslav Rajcic
http://www.spacetide.com
|
|
|
|
|
Hello,
I'm working on a dialog for one of my projects that allows the user to enter various program settings. Since most of the values that must be entered are numerical I have to check them to make sure they are in the right range, etc. I've created integer member variables for every edit box I have on my dialog and set the range on each, however, if the user presses backspace to clear the 0 that is automatically put in the edit box they get yelled at instantly with a very annoying "Please Enter A Number" message box. What I would like to do is change these variables to CStrings and then make sure that all values are exceptable when the user clicks the OK button of my dialog. However, when I create a handle to capture the BN_CLICKED message of the OK button, add some code and run my program, the dialog box remains when the user presses OK. The dialog box is invoked from the rest of the program in an if statement: if (MyDialog.DoModal()==IDOK) ... How can I have my dialog do all necessary value checking when the user clicks OK and still close and return IDOK to the main program? I'm new to the world of MFC and Visual C++ and I haven't had any luck finding anything like this. I really appreciate any help, thanks!
Joseph LeBlanc,
unixd0od@hotmail.com
|
|
|
|
|
Ah - the dreaded M$ screwed up DDX bug.
You make them CStrings, as you thought, and keep the ints as a seperate variable. Hungarian notation is good here, ie m_szValue/m_iValue. Now go to your dialog editor and click on each edit box and add a handler function for EN_CHANGE ( from memory, it's the one that you get when someone types text ).
Now in your handler, UpdateData() to get the value in, parse it and pass the value to the int only if it is valid, but bring up a dialog only if the value given is positively wrong, rather than empty or on the way to being right ( i.e. if you accept 5-100, don't complain about < 100 until user presses OK, as they may have been entering 10, 27, 43, etc ).
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
If you do decide to override the click of the OK Button, the last line of that function should be CDialog::OnOK();
so:
void MyDialog::OnOK()
{
.......... //whatever
CDialog::OnOK();
}
|
|
|
|
|
What I'd like to do is send a simple text e-mail message using whatever default mail settings the user has already set up on their machine with an easy call like:
CreateEmail("User@Somewhere","A Subject Here","Here is the important thing I wanted to send");
I'm writing an MFC app - and heck I can even assume Outlook or Outlook Express will be installed on the user machines if that makes the solution easier. W98, W2K or NT4 are the OS's I need to work with.
What is the easy way to do this - if every virus kid in the world can figure it out, it has to be easier than using 40 lines to talk to MAPI or the other partial solutions /examples I've seen so far. Somewhere I think I must just not be looking for the right function call.
Thanks!
Mark Terrano
|
|
|
|
|
Assuming that you know (or can get) the user's SMTP server name, and can assume that the user is connected to the internet, this article should suit your needs nicely.
http://www.codeproject.com/internet/csmtpconn.asp
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
OK, I am working on an article and I have only one thing to fix: saving. I wrote a simple app that loaded and saved a bitmap in different formats, worked fine. So I went ahead with this:
BOOL CGDIPlusPaintDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
CString name(lpszPathName);
CString ext = name.Right(3);
ext.MakeLower();
CLSID Clsid;
int ret;
if (ext == "jpg")
{
ret = GetCodecClsid(L"image/jpeg", &Clsid);
}
else if (ext == "gif")
{
ret = GetCodecClsid(L"image/gif", &Clsid);
}
else if(ext == "tif")
{
ret = GetCodecClsid(L"image/tiff", &Clsid);
}
else if (ext == "png")
{
ret = GetCodecClsid(L"image/png", &Clsid);
}
else
{
ret = GetCodecClsid(L"image/bmp", &Clsid);
}
if (m_Bitmap->Save(name.AllocSysString(), &Clsid, NULL)!= Ok)
AfxMessageBox("Failed to save");
return CDocument::OnSaveDocument(lpszPathName);
}
It just plain won't work !! I've traced it all through, the save returns Ok, but the file is 0 length. Here's the odd bit. If I hardcode a path like this:
L"c:\\image.bmp"
then it saves fine every time !! Argh !! I know my string is OK, I use the same method to load the files. I know saving is possible, a hard coded path saves. I know my string is correct going in, it creates an empty file at that location. Any suggestions ?
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Since it saves with a hard-coded string, experiment with different ways of passing the filename. T2COLE, CComBSTR, _bstr_t, etc.
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
Looks like I get the VB book on my desk next week. I was saving in the Documents OnSaveDocument handler. I didn't delete the call to the base class. Hard coded paths worked because they were not immediately erased by the base classes serialisation attempt.
In my defence, I worked on this at 3 in the morning, having just got up from 2 1/2 hours sleep. Not that this will save me from a fate worse than death - the VB Visual Quickstart Guide.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I am a C++ programmer with basic VB abilities.
I have a 3rd party Active X container that must be interfaced to our C++ system, here's the basic problem. I need to send to the Active X functions a BSTR*. I am even willing to write a VB wrapper to go around their container so I can pass it BSTR (which I tried). . . . .many questions.
1) How do you convert any basic string type to a BSTR* that VB will understand
or
2) How do you write the parameters for a VB function so that imported as an Active X it will want plain BSTR and not BSTR*
i.e. - this VB function declaration imports as an active X, but then in C++ you must pass in BSTR* (which I can't get to work)
Public Sub PackageFiles(XMLFileName As String, HTMLFileName As String, DropLocation As String)
. . . .
End Sub
|
|
|
|
|
I Ask the point number 1;
CString strOut = _T("aaaaaaaaaaa");
::SysFreeString(*pstrOut);
*pstrOut = strOut.AllocSysString();
return S_OK;
Where pstrOut is BSTR*
Cheers
Carlos Antollini.
|
|
|
|