|
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;
|
|
|
|
|
hi!
i really !! need to save my files in excel file format .
so plz help me
ron.
|
|
|
|
|
Saving .xls files programmatically is doable, but not what I'd call trivial - excel has a COM interface, or you could figure out the .xls format (yucch)
Just thought I'd mention that if you save your data as a comma delimited file (just crlf delimitted rows of quoted stings and text numbers separated by commas) you can drag and drop the whole file into excel. Works great.
|
|
|
|
|
Oops - I think I made a mistake there - the format I used was tab delimitted - I saved the file as text (both numbers and text) separated by tabs. So, tab delimitted, not comma delimitted.
However, if you change the file extention of the comma delimitted file to .csv it will work as I described it.
|
|
|
|
|
How you approach this is really going to depend on exactly what you want to achieve.
The Excel file format is very rich and flexible, and as someone who has coded an importer for a rather large portion of the BIFF7 format, I can tell you that you probably don't want to be screwing with writing to the binary format unless you have good reason. It's complicated, it's touchy, and although it is a pleasurable intellectual challenge, it is very, very time consuming.
So, Excel will import dozens of standard file formats as simple as DOS text, that might be an option.
As Tim (father Tim as he was known to us ) has stated you can do a great deal by using Excel through COM automation.
If you simply need to place text and values (not formulas or formatting) into an Excel file, then there is an Excel file driver for ODBC that will do the trick. I'm almost positive the driver is freely redistributable, but you'll have to do your own research on that.
HTH,
D
|
|
|
|