|
there are 2 classes on codeproject by pj naughter ... one for smtp and one for mapi ... both work well ... search for articles by him
rock on pj
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
in an MDI or SDI in BEGIN_AFX_MESSAGE jus add this two lines and set the ID of the following menu button
ON_COMMAND(ID_FILE_SEND_MAIL, OnFileSendMail)
ON_UPDATE_COMMAND_UI(ID_FILE_SEND_MAIL, OnUpdateFileSendMail)
BLaZe
|
|
|
|
|
Okay, I've finally found a reason to use COM for something.
I wrote a (regular) DLL using VC++ 6.0 to perform a task - reading an HTML file, parsing out the tags, and making the data available to the calling executable. This DLL uses MFC (CString, CFile, and the CxxxxArray classes) to aid in this task. When using this DLL from another C++ program, it works fine because the parameters being passed between the executable and the DLL are of type char*. Writing it as a regular DLL also provided easier/faster debugging of the core code within the DLL. Convinced that it worked as intended, I moved on.
I wrote the code so that people could write programs in other languages that use my code. After thinking about leaving it as a DLL and letting other folks worry about how to use it, I decided I'd go ahead and turn it into a COM object.
I wrote the ATL com object (using a simple ATL interface object) and it compiles just fine. However, I don't see a way to add it automagically to my application. I looked through Project|Add to Project|Components & Controls, but the com object I wrote doesn't show up anywhere.
Next, I tried creating an ATL COM object using an ActiveX interface object, and I still can't find the resulting ATL COM object with the tools provided by MS.
I even tried browsing to the DLL that contains the DLL and Visual Studio tells me the component is not a recognizable component.
What am I doing wrong?
|
|
|
|
|
you can always just add a line like this to your stdafx.h:
#import "myAtlThing.tlb" no_namespace
this will create .TLI and .TLH files in your debug directories. these are "smart pointer" wrappers for your ATL objects.
usage is easy. if your object is named "MyATLObject"
MyATLObjectPtr atlobj;
HRESULT hr = atlobj.CreateInstance("MyATLServer.MyATLObject");
if (!SUCCEEDED(hr))
{
AfxMessageBox("Create failed");
return FALSE;
}
...
it's not as nice as the MFC wrapper, but it works OK.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Thanks, I'll give that a shot.
Maybe what I'm after is what Visual Studio 7.0 is supposed to provide - seamless integration between ATL and MFC...
|
|
|
|
|
Hi,
I'm trying to run a console app without its console in win98. I just want to pop up a cancel dialog while the app is running.
I can run the app(using CreateProcess(..)), I can pop up the cancel dialog(dlg.Create()) but the console appears every time.
Heres my function to run the app and display the console:
(Does CodeProject use tags for formatted code? Guess I'll find out...)
[code]
//take a pointer to the command line string
BOOL run_console_app(const char* command)
{
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
BOOL all_is_well = FALSE; // Did program run without interruption and return 0?
CMyCancelDlg dlgCancel;
DWORD error;
if ( ! is_program_present(command) )
{
//show error dialog
error_message("Program file [%s] not found in path", command);
return FALSE;
}
// Initialize the process environment
GetStartupInfo(&si);
si.dwFlags |= STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
// Disable the mainframe window so that the user cannot invoke another
// command while this is completing.
GetFrameWindow()->EnableWindow(FALSE);
// Create a cancel dialog so that the user may abort the procedure.
if ( dlgCancel.Create(CRmanCancel::IDD, NULL) )
{
dlgCancel.ShowWindow(SW_SHOW);
dlgCancel.UpdateWindow();
}
// Start the child process.
if( CreateProcess(NULL, // No module name (use command line).
command, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // bInheritHandles
NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, // Creation flags.
NULL, // Use parent's environment block.
SILVER.paths.silver, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi )) // Pointer to PROCESS_INFORMATION structure.
{
CWaitCursor wait;
while(GetExitCodeProcess(pi.hProcess, &error))
{
MessagePump(); //keep windows events going -
//returns after handling event messages
if( error != STILL_ACTIVE)
{
if ( ! error )
all_is_well = TRUE;
break;
}
if ( dlgCancel.m_DidCancel )
{
::TerminateProcess(pi.hProcess, -1);
break;
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, 500 );
}
}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
AfxGetMainWnd()->EnableWindow(TRUE); //enable main frame window when completed
if ( dlgCancel.GetSafeHwnd() )
dlgCancel.DestroyWindow();
return all_is_well;
}
[/code]
Incidentally, this all works fine on win2000.
Anybody know what I'm missing?
Thanks,
Josh
josh@schroff.com
|
|
|
|
|
Hi,
What's the best way to get a bitmap handle from a icon?
TIA
|
|
|
|
|
|
|
hi
i have placed a RichTextControl in a dialogbox.i want to know some
code about it
1.when i press enterbutton after adding some text in it cursor is not going to next line
2.how to write code for SetSelBold() and SetSelColor() and all these functions?
3.i'm giving the file name at runtime in my InitDialog() as below
::OnInitDialog()
{
CString str;
str = "D:\\Bose\\Opms\\src\\";
str += pDoc->GetModelTextName();
str += ".prs";
VARIANT var;
InitVariant(&var);
m_RichText.Loadfile(str,&var);
}
when i run my program it giving "The specified file/path is invalid"message. how to avoid it?
please help me if anybody know code for it
|
|
|
|
|
Hi
1. catch your enterbutton in
BOOL CYourDlg::OnApply()
{
// do something with m_RichText;
return FALSE;
}
also your can use OnChar(...) fiunction
2. a sample
m_RichText.SetSel(0,-1);
CHARFORMAT cf;
cf.dwMask = CFM_SIZE|CFM_COLOR|CFM_UNDERLINE;
cf.dwEffects = CFE_UNDERLINE;
cf.crTextColor = RGB( 0, 0,255);
cf.yHeight = 120;
m_RichText.SetWordCharFormat(cf);
3. the simplest way
try
{
...
m_RichText.LoadFile(..);
}
catch(...)
{
}
Mike.
|
|
|
|
|
Thanks for the help before about placing the dialog onto the top of all windows! It works great!! Thanks!
Now I want to know how I can move it from the center of screen to the right side?
Help is appreciated!! Thanks!
Ashman
|
|
|
|
|
use MoveWindow() or SetWindowPlacement()
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Use GetWindowRect to FIND the right side, then put values into the SetWindowPos function I showed you previously ( use SWP_NOZORDER to ignore the first parameter ). As lauren said, you can also use MoveWindow
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hi, I am writing an application for a game. I want it to be infront of the game as well! The game, The Settlers IV was written in DirectX. Is there a way to keep my dialog in front of this one with out it stuffing the game up?
Ashman
|
|
|
|
|
There is a way to put the dialog in front, if it stuffs the game up remains to be seen. Inside the OnInitDialog method, do this:
SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
This will put the window on top of the Z order, even if a window underneath is clicked, and ignore the numeric paramters which position and size the dialog respectively.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
|
Hi there,
i'm trying to change the caption of a CPropertyPage at run time.
In OnInitDialog() of this CPropertyPage I'm trying :
1. CWnd::SetWindowText ("XXXX"), and also
2. CPropertyPage::m_psp.dwFlags = m_psp.dwFlags | PSP_USETITLE;
CPropertyPage::m_psp.pszTitle = "XXXX"
After both tries i call UpdateData() and/ Or Invalidate() and nothing.
I'm trying to change both in Wizard Mode and Normal but nothing happens there.
Can somone help me with that ????
Thanks alot,
Ariel.
|
|
|
|
|
Hi
you can use SetTitle() function - before,after or in OnInitDialog
check also that you haven't define your own WM_USER + 111 message
Mike
|
|
|
|
|
Hi there,
I'm trying to Select a row in a CListCtrl using the
CListCtrl::SetSelectionMark(idxSel);
and i'm calling this method in OnInitDialog() of a CPropertyPage.
But this dosen't really worked for me !! I tried to Use UpdateData() and Invalidate() on the view to see if this will help but still no selection seen on the screen (although i do think there is something selected but not shown).
Can somone help me with that ????
Thanks alot,
Ariel.
|
|
|
|
|
|
Thanks alot it worked
Ariel.
|
|
|
|
|
Hi
I'm using the MSHFlexiGridControl and want it to display the results of a query. But even though the query has more than one record, the MSHFlexiGridControl only shows one record. I've followed the MS example; making sure to call Refresh.
My code looks like:
<br />
pVisitRecordSet = pCommand->Execute(&vNull, &vNull, adCmdText);
<br />
<br />
m_FlexCtl.SetRefRecordset(pVisitRecordSet);<br />
<br />
<br />
m_FlexCtl.Refresh();<br />
Thanks for any help. BTW.. For programming the ADO controls in C++ is it just a matter of reading any VB documentation we can find, or is there some C++ documentation out there?
|
|
|
|
|
Can someone show me the correct way to store a date in a _variant_t type? I'm using:
_variant_t varTest;
varTest = _variant_t( 30000.3002, VT_DATE );
But how do I control the date stored. Which calulations are there that convert a date derived from the CTime functions to the float required by the _variant_t constructor???
Any clues???
|
|
|
|
|
Try:
COleDateTime theTime(1978, 12, 12, 6, 0, 0);
_variant_t vTime; vTime.vt = VT_DATE;
V_DATE(&vTime) = theTime;
|
|
|
|