|
This will activate the currently selected screensaver:
BOOL bScreenSaverEnabled = FALSE;
BOOL bStatus = ::SystemParametersInfo
(SPI_GETSCREENSAVEACTIVE, 0, &bScreenSaverEnabled, 0);
if (bStatus && bScreenSaverEnabled)
AfxGetMainWnd()->SendMessage (WM_SYSCOMMAND, SC_SCREENSAVE);
[edit]
Ooops, I just re-read your post. Use CreateProcess() to execute an app from within your app.
[/edit]
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
Thanks Mike - I think I'll punt and go with WinExec().
If these are the last lines of my code:
////////////////////////
return; // return from next to last function
}
if (QuizAvg>0.79)
{
WinExec (“a:\ballfusion.exe”, SW_SHOWNORMAL );
}
Cout<< “Sorry – your score was less than 80%.”;
Clearscreen();
}
Return 0; // end of Main()
}
Do my B+ students get the executable screen saver no matter what (in a desktop setting) and my C students get the "sorry message"?
Where would the program finalize and is there good form for ending such a program that "tosses off" to another application (destructors, clearing mrmory and the like)? Thanks!
|
|
|
|
|
You need an else block there, as it is now the "sorry" message will be printed all the time.
THe original program does not end after WinExec() , you need to do cleanup in the same way as when you don't call WinExec() .
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
I even hear the Windows "OMG I booted up fine" sound.
-- Paul Watson diagnosing hardware problems.
|
|
|
|
|
thanks Mike - I re-read your tutorial. Some would have you avoid WinExec, but I'm a beginner and need "EZ".
So--- I follow the need for Else, I'll reverse the order so "C" students are handled first, and close out open classes & pointers prior to the IF-ELSE. But if the screensaver returns to C++ code and finds itself at a "return 0;" at the end of Main(), why won't my program end itself?
Appreciate it!
". . .gonna keep on tryin' - til I reach my highest ground"
|
|
|
|
|
hi,
is there any way so i can print a report created in MSACCESS database through a VC++ code suppose that the report name is "report1" and it is in a database called "db1.mdb",waiting for help, thanks
|
|
|
|
|
i am working with a directsound program. i need IDirectNotify to place some notification when playing sound. but i found that i can't get it through the function-QueryInterface. it always fails. please help me. thanks
laia.
|
|
|
|
|
HRESULT SetStopNotification(HANDLE hMyEvent,
LPDIRECTSOUNDBUFFER8 lpDsbSecondary)
{
LPDIRECTSOUNDNOTIFY8 lpDsNotify;
DSBPOSITIONNOTIFY PositionNotify;
HRESULT hr;
if (SUCCEEDED(
hr = lpDsbSecondary->QueryInterface(IID_IDirectSoundNotify8,
(LPVOID*)&lpDsNotify)))
{
PositionNotify.dwOffset = DSBPN_OFFSETSTOP;
PositionNotify.hEventNotify = hMyEvent;
hr = lpDsNotify->SetNotificationPositions(1, &PositionNotify);
lpDsNotify->Release();
}
return hr;
}
Don't try it, just do it!
|
|
|
|
|
I just use these codes to get it, but the QueryInterface always failed. Then I try to get the interface to the CaptureBuffer, it is ok. Why these happened?
laia
|
|
|
|
|
I am programming with unicode.And I don't know how to send a character with the code > 0xFF.Anyone know it.
Thank you very much...
|
|
|
|
|
Hi,
I don't know what do you mean with "...how to send a character..." but if what you want is assign a UNICODE character to a variable, this is how
TCHAR c = 0x0100;
Now if you are talking about UNICODE strings, use BSTR or one of the classes that encapsulate it, CComBSTR or _bstr_t.
Fabian
|
|
|
|
|
Sorry for my ambiguous question.I want to send a message WM_CHAR with a code > 0xFF but when I use the following code :
wParam = 0x01ff
It send a character with code = 0xff.
|
|
|
|
|
Hi,
Could you be more specific?
If I do this
TCHAR t = 0x01FF;
SendMessage(WM_CHAR, (WPARAM)t, NULL);
when I process the message I get wParam == 0x000001FF
Fabian
|
|
|
|
|
Silly question, but do you have _UNICODE and UNICODE defined? If you don't, TCHAR will equate to char..... and:
TCHAR t = 0x01FF;
SendMessage(WM_CHAR, (WPARAM)t, NULL);
Will truncate t to 0xFF when stored in a char varible.
Try being explicte about what character set you are sending -
wchar_t t = 0x01FF;
SendMessage(WM_CHAR, (WPARAM)t, NULL);
|
|
|
|
|
Hi All,
I'm trying print a bitmap but the print preview works well, the bitmap appears nolmaly but when I print, the bitmap don't appears. I'm using a MFC MDI project and the OnBeginPrinting and OnPrint.
All other elements in the printed sheet appears normaly.
Thanks in advance
Sergio Batarce
|
|
|
|
|
|
Soon after I had put this question, I find your article. It is helping me too mutch. Thank you very much
|
|
|
|
|
Hi all.
I am using a class found here http://www.codeproject.com/database/cspreadsheet.asp to create an excel spreadsheet ( i believe it uses ODBC )
It works great except I cannot, from my code, get the cells to autofit. That is, when you load up the file in Excel, a lot of the contents of the cells get cut off, because the cell is not big enough. I need to be able to tell it to autofit (automatically through code) or be able to specify the width of each column of cells. If I bring up the file in excel, and select all of the cells, then click on Column->Autofit, it makes it look right instantly ... However, I am planning on rolling out a program that generates reports and I don't want to have to tell the users that they have to do this every time they open a report.
Any help in the right direction would be appreciated!
-Shultas
|
|
|
|
|
Hi
ODBC, ADO or OLEDB will only allow you to manipulate data in and out Excel files, to go beyond that, you should use Automation, then you will be able to do, programmatically, anything you have to do.
You can take a look here to start, SAMPLE: XLCLIENT: Automation Client for Excel, also search the MSDN for more info.
Fabian
|
|
|
|
|
Hi
I am now on stage to integrate the HTMLHelp build with HTML Workshop >> Help.chm
In my project i had included the htmlhelp.h file and also the library htmlhelp.lib (both taken from HTML Help Workshop folder).
Now what to do?
Where to call the initialise or state that this is the html help file which has to be linked with teh project?
WHere to use following API i.eHTMLHelp?
HtmlHelp();
Urgent, Please help me in this respect?
Sandeep
Leave your mark wherever you go
|
|
|
|
|
Help topics are usually linked to different elements (dialogs, views) of your app. Here's what I do (which is slightly different from MS' process):
For every dialog (eg: CMyDialog ), define a unique constant (eg: Help_MyDialog ). Keep these constants in the file MyAppHelp.h . Include this file as a map in your HtmlHelp project. Ids in the file will map to your .chm 's topic ids.
Add a "Help" button to your dialog. It's handler should execute this:
HWND hWndHelp = HtmlHelp (NULL, strHelpFile, HH_HELP_CONTEXT, Help_MyDialog); where strHelpFile is the full path to your app's .chm file.
Add a handler for the WM_HELPINFO message. This message is sent whent the user clicks the F1 key. In its handler, just call your Help button handler.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
in MainFrm.cpp
==============
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.style = WS_OVERLAPPED | WS_CAPTION
| WS_BORDER | WS_SYSMENU
| WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME ;
cs.cy = 600;
cs.cx = 1000;
return TRUE;
}
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
POINT m_ptMinTrackSize;
m_ptMinTrackSize.x = 500;
m_ptMinTrackSize.y = 300;
lpMMI->ptMinTrackSize = m_ptMinTrackSize;
CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
in ProgView.cpp
===============
pWnd = GetTopWindow();
for(pWnd = GetTopWindow(); pWnd;) {
pWnd->GetWindowRect(&Rect);
ScreenToClient(&Rect);
id = pWnd->GetDlgCtrlID( );
if ((id == IDC_1) || (id == IDC_2);
Rect.OffsetRect(dx,0);
Rect.right = Rect.right + dx / 2;
Rect.bottom= Rect.bottom + dy;
}
if ((id == IDC_3) || (id == IDC_4);
Rect.OffsetRect(0,dy);
}
//...
pWnd->MoveWindow(&Rect);
pWnd = pWnd->GetNextWindow();
}
in Prog.rc
==========
IDD_PROG_FORM DIALOG DISCARDABLE 0, 0, 600, 300
STYLE WS_CHILD | WS_THICKFRAME
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "List1",IDC_1,...
CONTROL "List1",IDC_2,...
CONTROL "",IDC_3,...
CTEXT "",IDC_4,...
END
I do not arrive has resources control on the window IDD_PROG_FORM:
A resize with mouse do not change the dimension of IDD_PROG_FORM and I have so " scroll bar " appear
When I reduce too much the main window.
Need of help thank you
|
|
|
|
|
I just wonder how ::Ellipse and ::ArcTo were implemented(or CDC::Ellipse , CDC::ArcTo in MFC library), I really wish I could have a chance to see the source code of those functions, or less than that, an idea how it was possible to draw an ellipse(not a circle) on the screen, by being given a mere boundary rectangle.
I guess there got to be a lot of plane geometry involved, hell, wouldn't it be terribly time consuming to calculate coordinates of every single point on the arc?
|
|
|
|
|
|
Hi,
For most of the devices, the GDI will just delegate the drawing to the device itself because the drawing has been optimized by the manufacturer of that piece of hardware. Check the API GetDeviceCaps, it tells you if the hardware device is capable to draw the primitive, in this case, of an ellipse.
Fabian
|
|
|
|