|
Thanks, but I need to disable ctrl- and shift- instead of enable them. All articles I searched about access key in MSDN, don't mention that ctrl- and shift- are access keys, so I doubt that ctrl- and shift- are by default.
|
|
|
|
|
Hello!
I've got this thread function and in the postmessage line i'd like to send a message to the main view of the program. (it's an MFC project).
<br />
DWORD WINAPI CHilos::ThreadProc(LPVOID objeto)<br />
{<br />
CHilos* thread=(CHilos*)objeto;<br />
while (thread->Alive)<br />
{<br />
while((thread->Alive)&&(thread->Active))<br />
{<br />
thread->Work();<br />
}<br />
}<br />
::PostMessage(HWND_BROADCAST, WM_ONFINISH, 0, 0);<br />
return true;<br />
}
The project is called hiloss, and in hilossView.cpp i declared in the message map:
ON_MESSAGE(WM_ONFINISH, OnThreadended)
and then in the same file there's the definition of the OnThreadended function.
The problem is with the postmessage is that the message never reaches the top window, actually when i debug the project, it never gets into the OnThreadended function.
Is HWND_BROADCAST ok? i think there's the problem. I want to send a message to the ChilossView class, which is the main window of the project, but i don't know how.
thanks!!
|
|
|
|
|
HWND_BROADCAST won't send the message to your view. It sends the message to all the top-level windows in the system. In MFC, this is the instance of your CMainFrame class. You'll either have to the send the message to your view directly, or handle the message in CMainFrame .
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
how could i send the message directly to the view?
thanks
|
|
|
|
|
When is OnThreadended been called? in WM_ONFINISH?
And the OnThreadended will call the ThreadProc which will post WM_ONFINISH?
Seems like an deadlock for me.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Anthony_Yio wrote:
When is OnThreadended been called? in WM_ONFINISH?
yes.
Anthony_Yio wrote:
And the OnThreadended will call the ThreadProc which will post WM_ONFINISH?
no, OnThreadended does other things
thanks for answering!
|
|
|
|
|
Hey,
I am tring to teach my self C++ from a book. And it is not going as well as i planned. I am tring to make the first program in the book and I keep getting the same error. I am using Visual C++ 6 as my compiler. The Program is very simple (Not for me i guess haha):
// myfirst.cpp--displays a message
#include "stdafx.h" // a PREPROCESSOR directive // make definitions visible
int main() // function heading
{ // start of function body
cout << "Come up and C++ me some time."; // message
cout << "\n"; // start a new line
return 0; // terminate main()
} // end of function body
The Error I always get is:
myfirst.cpp
c:\Documents and Settings\Ben Quinn\My Documents\Visual Studio Projects\myfirst\myfirst.cpp(6) : error C2065: 'cout' : undeclared identifier
c:\Documents and Settings\Ben Quinn\My Documents\Visual Studio Projects\myfirst\myfirst.cpp(7) : error C3861: 'cout': identifier not found, even with argument-dependent lookup
I am using the 32bit App Option like the book said to use. there is one difference between mine and the book's code. Their's code says:
#include <iostream>
using namespace std;
But whenever I use that I get the Error:
Compiling...
myfirst.cpp
c:\Documents and Settings\Ben Quinn\My Documents\Visual Studio Projects\myfirst\myfirst.cpp(12) : fatal error C1010: unexpected end of file while looking for precompiled header directive
I hope some one can help me out. I really wana get past the first 3 pages.
Thx
- Hidden
|
|
|
|
|
what about at the top?
#include <iostream.h>
Teach Yourself C++ in 21 Days - Second Edition
is a good way to learn c++. It's free. look it up in google
|
|
|
|
|
|
Hi all!
I've been tring to put a bitmap background image on the main Dialog but nearest i can get is this:
CDC* pDC=GetDC();
CDC old; //New device context used as the source DC
//Creates a deice context compatible to pDC
old.CreateCompatibleDC(pDC);
CBitmap dlg_bmp;
CRect rect;
GetClientRect(&rect);
dlg_bmp.LoadBitmap(IDB_BITMAP3);
CBitmap* oldbmp= old.SelectObject(&dlg_bmp);
pDC->BitBlt(rect.left, rect.top, rect.Height(), rect.Width (),&old,0,0,SRCCOPY);
old.SelectObject(oldbmp);
dlg_bmp.DeleteObject(); //Deletes the bitmap
Invalidate();
when this runs the bitmap is loaded and it overrun the other controls hiding them
If some one help me i'd be very gratefull
AI_Warrior
|
|
|
|
|
You need to handle WM_ERASEBKGND and paint the bitmap in response to that message.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
try setting the background brush of the dialog box by usning the setclasslong method use GCL_HBRBACKGROUND as the index in the api.
|
|
|
|
|
Hi!
I have a problem with setting the character set in my ListBox (List). When I create a CFont object with a specific character set and I set that font in the Device Context recieved from the ListBox, then it is OK. I can write through that DC in the chosen charset. See Code :
CFont * font = new CFont;
CFont *oldFont;
CPaintDC dc( List );
font->CreateFont (28,0,0,0,700,0,0,0,
RUSSIAN_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH|FF_DONTCARE, "Arial");
oldFont = dc.SelectObject( font);
dc.ExtTextOut(10,170,0,NULL,"some text",
strlen("some text"),NULL);
!!!!!!!!! BUT !!!!!!!!!
If I set that font right in my ListBox and want to have the text added with code :
<br />
List->SetFont( font, TRUE); <br />
List->AddString( "some other text" ); <br />
in the chosen charset, then it DOES NOT work !
However the added text has the other parameters of the chosen font ( Height and so on) but the charset is the original (standard) one
Does anyone know how to force the ListBox to accept the charset from the font also ? Or it might be a bug in my Visual Studio ?
PLEASE HELP!
|
|
|
|
|
I have been trying to have an Edit Box take the Tab key as a simple move off the control - just tab around all the controls with Tabstop set.
Currently the Tab acts as an end to data input (i.e. like a Return or Enter key pressed). I did start to Derive the Edit Box control, but got stuck, see code below!
<br />
#include "stdafx.h"<br />
#include "MyEdit.h"<br />
<br />
<br />
<br />
IMPLEMENT_DYNAMIC(CMyEdit, CEdit)<br />
CMyEdit::CMyEdit()<br />
{<br />
}<br />
<br />
CMyEdit::~CMyEdit()<br />
{<br />
}<br />
<br />
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)<br />
ON_WM_GETDLGCODE() <br />
END_MESSAGE_MAP()<br />
<br />
<br />
<br />
UINT CMyEdit::OnGetDlgCode()<br />
{<br />
return DLGC_WANTTAB;<br />
}
Currently the Edit Box (MyEdit) only processes the TAB key, I want it to process all keys but with the Tab key just move on to the next tabstop.
Help!
grahamfff
|
|
|
|
|
Lookin' for a l'il help here.
How do you launch a file from within a compiled C++ project?
I'd like my file to have a Switch where Case 1 is print this picture on the screen, Case 2 is leave program and launch a:\screensaver.exe
Is such a thing possible?
Thx
". . .gonna keep on tryin' - til I reach my highest ground"
|
|
|
|
|
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...
|
|
|
|