|
1) You just need to a create a normal command button to do this. In the command handler, you just need to call:
ShowWindow(SW_MINIMIZE);
2) To access an outside readme file, I assume you mean you want to use the user's default viewer to view an external file. If so, the easiest way is to use ShellExecute with the "open" verb, which will look up the user's selected text file viewer for you. I usually try to open the file in Notepad if it fails:
int viRes = (int)ShellExecute(GetSafeHwnd(), "open", "my_file_to_read.txt", NULL, "C:\\Temp", SW_SHOW );
if (viRes == SE_ERR_NOASSOC)
{
STARTUPINFO vtStartupInfo;
PROCESS_INFORMATION vtProcessInfo;
CString vcstrCommand;
CString vcstrParams;
DWORD vdwLen;
vdwLen = GetWindowsDirectory(vcstrCommand.GetBuffer(_MAX_PATH), _MAX_PATH);
vcstrCommand.ReleaseBuffer(vdwLen);
vcstrCommand += "\\Notepad.exe";
vcstrParams = vcstrCommand + " ";
vcstrParams += m_cstrLogFilename;
memset(&vtStartupInfo, 0, sizeof(vtStartupInfo));
vtStartupInfo.cb = sizeof(vtStartupInfo);
if (!CreateProcess(vcstrCommand, vcstrParams.GetBuffer(vcstrParams.GetLength()), NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &vtStartupInfo, &vtProcessInfo))
{
vcstrParams.ReleaseBuffer();
CString vcstrMsg;
vcstrMsg.Format("The logfile \"%s\" could not be opened using Notepad.", (LPCTSTR)m_cstrLogFilename);
AfxMessageBox(vcstrMsg);
}
else
vcstrParams.ReleaseBuffer();
}
else if (viRes < 32)
{
CString vcstrMsg;
vcstrMsg.Format("The logfile \"%s\" could not be opened using your default viewer.", (LPCTSTR)m_cstrLogFilename);
AfxMessageBox(vcstrMsg);
}
Hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Thank you so much for your help, I can't believe how simple it were. Again, thanks, I appreciate it.
|
|
|
|
|
Hi all,
I just create one program using timer and it connect to database to process something. I try to leave my program running one day, but what I get next morning is it prompt out a dialog box say "Cannot generate SSPI context".
I don't know what it is. + +
Can anybody help me to resolve on this??
I really appriate it. Thank you.
FM
|
|
|
|
|
I just create one program using timer and it connect to database to process something.
This means that you open database, write something, and close database every XXX seconds?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Yes. But it will continue to loop after it finishing the task (open, write and close). This is done by using KillTimer and SetTimer back.
Thanks in advance.
p/s: My supervisor said it is because my program keep generating a user in the database until it exceeds the limit and gives me that dialog box saying "cannot generate SSPI context". Could this be the problem?? But I already check my code and I close every database that I open.
+ =
FM
|
|
|
|
|
My supervisor said it is because my program keep generating a user in the database until it exceeds the limit and gives me that dialog box saying "cannot generate SSPI context". Could this be the problem??
Exactly, it looks like resource leak. SSPI == Security Support Provider Interface; it's used to "establish authenticated connections and to exchange data securely over those connections".
To avoid problems with long period of time before error occurs, replace the timer and use database in a tight loop: you should see the problem much earlier.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
How to replace the timer, and with what?? And can I know what do you mean by using database in a tight loop??
This application cannot be stopped or closed, unless there is a network connection error.
Could be the network error??
Thank you so much for your help.
FM
|
|
|
|
|
To diagnose and fix the error you need to make it easier to reproduce - waiting many hours for SSPI context error is a waste of time, right? Two solutions are possible:
1) easier: set the timer elapse period to 10 msec.
2) create an infinite loop that repeatedly calls database code. This will be marginally 'faster', but application will not respond to menu selections, etc.
I'm not sure if automatic error detection tools like BoundsChecker can detect problems with SSPI. If you have such a tool, give it a try.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Dear Sir,
I have a question about how to kill a process:
We know, when a child process is created in the parent process, the child
process can be killed with the TerminateProcess(hHandleProcess, 1),But if
others child processes are created by the child process, how can I
kill them all.
For Example (from Tornado IDE):
When we use GNU tools to compile and link the source files, we usually use
the make.exe to interpret the makefile document, so the make.exe can be a
child process of a application(may be an IDE). But we know make.exe
will create may sub-processes(gcc.exe, ld.exe, make.exe, ect.), so how can I
kill the child process(make.exe) and all it's sub-processes in the application
(IDE).
I hope your help!!
dong geming
|
|
|
|
|
You could use job objects, but they are available only on Windows 2000. The other option is to enumerate all processes in the system, retrieve parent-child information and kill apropriate ones. Note that there's no universal method for this - you'll have to use different APIs on Win9x and NT.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I'm using a CListCtrl in report mode and I want to use it with some multiline text (i.e. it has carriage lines in it). The problem is that the edit control the list view uses are single line elements and do not understand carriage returns or line feeds so i get a bunch of wonderful bars in the text. Anyone have an good solutions to the problem?
Okay I got the owner draw thing to work and I know have carriage returns. The problem is I can't see the text as the row height does not change. Anyone have any ideas on how to change the row height?
-Mathew
|
|
|
|
|
You'll have to use owner-draw. Search for LVS_OWNERDRAWFIXED in VC++ help, there's also sample in KB article Q131788.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have the owner draw part working, but I don't see how to get it to recognize carriage returns and line feeds. Any ideas?
Mathew
|
|
|
|
|
|
i'm taking a corispndence course and i'm on my second excersize. useing appwizard, i need to make a grid useing the fgrid control, np but i need to code a command button to clear all fields in the grid. is there some kind of short method for clearing them without havin to code each field? like a clear all fields kinda code?
|
|
|
|
|
There is no such thing as fgrid according to MSDN. There are several grid controls and you're obviously not a confident typist, so I presume you've made a typo.
If it's one of the grids provided as COM object then when you #imported it you would have got a class that calls the objects methods and you would be able to browse that for all the available methods.
If you can tell us which grid you're using, someone here may be able to help you.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Is there a good place I can park a global variable so that every class has easy access to it?
Thanks
Richard
|
|
|
|
|
stdafx, if you must resort to a global - they are Satanic and should be avoided.
I put stuff in my CWinApp derived class or CMainFrm, because I can get a pointer to it from anywhere.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Hi, do you guys remember that sheep program that's a screen mate? Basically it's a transparent image on the desktop that can move around. I was wondering if VC++ is the language I would have to use to make something similar to this. I want a transparent gif on my desktop without a window frame. Please help.
here's a link where you can download it.
http://www.geocities.com/Athens/Oracle/7565/screen.htm
|
|
|
|
|
Use CWindowDC dc(NULL) to get a device context of the screen. Then you can copy off the old image, draw your new one on, etc. I dunno if there is a better way to do animation than this, as I've never tried.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Hey!
In Win2k, if I call SetCurrentDirectory() with a specific directory,
it appears to work until I use a CFileDialog.
When the file open dialog appears, it usually opens in "My Documents".
SetCurrentDirectory() doesn't seem to fail, and calling GetCurrentDirectory()
returns the right directory name, but CFileDialog just seems to be
completely oblivious of my directory change. This doesn't happen in Win98,
so I'm wondering if there's a reason why the behaviour changed in Win2k.
Another question would be: if SetCurrentDirectory() doesn't work in
Win2K, what does?
Thanks!
Steve
|
|
|
|
|
Use this...
CFileDialog dlgFile;
dlgFile.m_ofn.lpstrInitialDir = _T("C:\\Winnt\\System32");
the lpstrInitialDir variable is what controls where the file dialog starts in, and if its empty it will start in My Documents or whatever the default is.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Cool, it worked!
Thank you much.
Steve
|
|
|
|
|
I can't seem to disable a button, so that it is showed as grayed-over. However, if I call IsWindowEnabled() after attempting to disable it, it says that it is disabled. Disabling it by setting its property to disabled doesn't work either. It still shows itself as enabled when the app launches.
The button is on a dialog-bar, and I attempt to disable it via the following:
m_wndDialogBar.GetDlgItem(IDC_MY_BUTTON)->EnableWindow(FALSE);
Calling UpdateWindow() doesn't seem to help at all either.
- John
|
|
|
|
|
I may be wrong here...as always. But...
I think your on the right track, but using the wrong thinking. A dialog bar is a dialog...but its not really a Dialog in the normal sense of things. Its really derrived from CControlBar like CToolbar. I think.
Try treating your CButton's like standard everyday toolbar buttons and use GetToolbarCtrl. ie:
CToolBarCtrl& myControl = m_wndToolBar.GetToolBarCtrl();
myControl.EnableButton(IDC_MYBUTTON, FALSE);
I'm really stabbing at shadows here, so if I'm wrong I never posted this. If I'm right...you bet I posted it.
Frank
|
|
|
|