|
Joaquín,
I tried what you said and overriding CWinThread::InitInstance works. Thanks! Now I have another question. If I declare several instances of this class they all seem to share the same variables. Maybe I am not saying that right so I will show you the code:
class Cw : public CWinThread
{
public:
DWORD delay;
DWORD freq;
BOOL InitInstance();
int Run();
Cw();
virtual ~Cw();
};
Cw::Cw()
{ delay = 0;
freq=1000;
}
Cw::~Cw(){}
int Cw::Run()
{ Sleep(delay);
Beep(freq,500);
return 0;
}
BOOL Cw::InitInstance(){Return TRUE;}
////////////////////////
Then i have four of the instances and i think i should hear 4 tones one after the other but i don't. Are they all sharing the same delay and freq?
w = new Cw();
w->freq=5000;
w->CreateThread();
x = new Cw();
x->delay=500;
x->freq=2000;
x->CreateThread();
y = new Cw();
y->delay=1000;
y->freq=1000;
y->CreateThread();
z = new Cw();
z->delay=1500;
z->freq=500;
z->CreateThread();
///////////////////////////////////////////////
The above code should sound like this:
w = new Cw();
w->freq=5000;
w->CreateThread();
Sleep(500);
x = new Cw();
x->freq=2000;
x->CreateThread();
Sleep(500);
y = new Cw();
y->freq=1000;
y->CreateThread();
Sleep(500);
z = new Cw();
z->freq=500;
z->CreateThread();
|
|
|
|
|
Joaquín,
Please ignore my message above. It was a bad test. If I change the values it will work better. Thanks again for your help.
(But I still wonder about my OnIdle question: The only other thing that I know Run() does is call OnIdle(). Can I safly not call OnIdle() - I don't plan to overide it? )
Here is how I getting my test to work (I increased the delay):
//Sleep(500);
x = new Cw();
x->delay=3000;
x->freq=2000;
x->CreateThread();
//Sleep(500);
y = new Cw();
y->delay=6000;
y->freq=1000;
y->CreateThread();
//Sleep(500);
z = new Cw();
z->delay=9000;
z->freq=500;
z->CreateThread();
|
|
|
|
|
I'm not the guy you want to chat with.
please pay attention to my question ...about ocx, I had nothing to do with your subject.
Bye.
|
|
|
|
|
I've been trying to return data from an ODBC database and display it in a tabbed dialog (property page). The code compiles just fine, but I get a runtime error during execution. Specifically,
ERROR MESSAGE:
<br />
TRACE0("ASSERT_VALID fails with NULL pointer.\n");<br />
if (AfxAssertFailedLine(lpszFileName, nLine))<br />
AfxDebugBreak();<br />
return;
I know the CRecordset class I created works fine (I've used it before in a single dialog page). The problem seems to occur during data exchange in the CPropertypage class. Here's the code that is suspect:
CPROPERTYPAGE SOURCE:
<br />
CPersonalData::CPersonalData() : CPropertyPage(CPersonalData::IDD)<br />
{<br />
m_pSet = NULL;<br />
}<br />
<br />
void CPersonalData::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CPropertyPage::DoDataExchange(pDX);<br />
DDX_FieldText(pDX, IDC_TITLE, m_pSet->m_TITLE, m_pSet);<br />
}<br />
<br />
CRecordset* CPersonalData::OnGetRecordset()<br />
{<br />
return m_pSet;<br />
}<br />
In addition, m_pSet is defined in the header file for the CPropertypage as follows:
CPROPERTYPAGE HEADER:
<br />
class CPhysiciansListSet;<br />
<br />
class CPersonalData : public CPropertyPage<br />
{<br />
DECLARE_DYNCREATE(CPersonalData)<br />
<br />
public:<br />
CPersonalData();<br />
~CPersonalData();<br />
<br />
virtual BOOL PreTranslateMessage (MSG* pMsg);<br />
<br />
enum { IDD = IDD_PERSONALDATA };<br />
CPhysiciansListSet* m_pSet;<br />
};<br />
Any suggestions would be GREATLY appreciated. I've been screwing around with this app for a week now on this one problem and I'm about to go crazy.
Thanks in advance.
|
|
|
|
|
I have a CHtmlView loaded with some HTML that i generate on the fly (loaded with IPersistStreamInit). it works fine - everything displays properly - yay.
the problem is when i try to do links within the document: links like <a href="#somelink">..</a> to <a name="somelink"> .
if i hit one of these, the browser takes me to a page that says "blank#somelink", not to the "somelink" on the original page.
since i'm loading this HTML stream dynamically, i can't use the res:// "protocol" and, "file://" doesn't work...
any ideas?
-c
Smaller Animals Software, Inc.
You're the icing - on the cake - on the table - at my wake. Modest Mouse
|
|
|
|
|
I nned to be able to get the main frame window from a worker thread with no GUI component. AfxGetMainWnd() get the main window for the current thread - the worker thread and so returns null.
Any ideas on how to get the MainFrame from the primary thread?
Thanks,
Giles
|
|
|
|
|
Pass HWND of MainFrame through thread parameters and then create CWnd object by CWnd::FromHandle(HWND) function in workeer thread
|
|
|
|
|
I thought of passing the handle, but was not sure if it would be okay from another thread. Despite that, I am updainting another window, but need to be able to get at the promary thread so I can attach to the Frane Window, and them the Status Bar.
Thanks,
Giles
|
|
|
|
|
Try AfxGetApp( )->m_pMainWnd
Nish
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|
|
Thanks Nish, will check it out.
Giles
|
|
|
|
|
Hio again.. I have a class (CCompanyHandler) which loads and saves a CObArray which is full of CObjects. The load file function calls the CObject constructors, and I'm trying to figure out how to destruct all of these objects created when loaded. I figure if I can overload the CCompanyHandler destructor then I should be able to have it destruct all of the CObjects, but I still have some sort of memory leak. Here is a trace:
CCompanyHandler:Constructor
CCompanyHandler:LoadFile
CCompany:Contructor <+ 1
CCompanyHandler:Constructor
CCompanyHandler:LoadFile
CCompany:Contructor <+ 2
CCompanyHandler:Constructor
CCompanyHandler:LoadFile
CCompany:Contructor <+ 3
CCompanyHandler:LoadFile
CCompany:Contructor <+ 4
CCompanyHandler:Destructor
CCompany:Destructor <- 3
CCompanyHandler:Destructor
CCompany:Destructor <- 2
CCompanyHandler:Destructor
CCompany:Destructor <- 1
As you can see the LoadFile() function of CCompanyHandler is what calls the constructors for the objects as it reads them.
TRACE("CCompanyHandler:LoadFile\n");
try
{
CFile fileMyFile(m_strFileName,CFile::modeRead + CFile::modeNoTruncate); //open file for reading
CArchive arRead(&fileMyFile, CArchive::load); //open archive for loading
m_oaCompanies.Serialize(arRead); //call serialize function to populate m_oaCompanies
arRead.Close(); // close archive
fileMyFile.Close(); // close file
return 1;
}
My problem is that if I call the loadfile() function multiple times it will keep creating instances of CCompany, and then my destructor doesn't get rid of it.. here is what my destructor does:
TRACE("CCompanyHandler:Destructor\n");
if (GetSize() > 0)
for (int i = 0; i < GetSize(); i++)
((CCompany*)m_oaCompanies[i])->~CCompany();
As you can see this only calls the destructor for each of the objects in the CObArray, not all of the objects which were actually made by the loadfile() function..
basicly i am clueless on proper destruction right now, and I'm getting tons of memory leaks when I debug, any suggestions on proper destruction of pointers and such will be MOST appreciated.
-dz
|
|
|
|
|
hi i connected an access database thru classwizard by creating a recordset class and connecting the database thru the following dialog. how do i run executesql command to acess related tables since i cannot find an automatically generated CDatabase class
|
|
|
|
|
Do you want to run a Query or execute a SQL Statement?;)
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
|
Hi all:
Do you know which software, service pack updates WinNT from older version of MSVCRT.DLL to newer ? (e.g MSVCRT.DLL 5.00.70220 -> 6.00.8797)
Thanks.
Hoang Le
|
|
|
|
|
|
I have a wrapper around the IPicture interface for drawing Gifs and jpegs that it is then used in an extended CStatic class. The code below shows the wrapper Render function which is called from the CStatic-derived OnPaint handler (also shown):
void CPictureCtrlSSL::OnPaint()
{
CPaintDC dc(this);
if (m_pict) {
CRect rcClient;
GetClientRect(&rcClient);
CRect rcImage(CPoint(0,0),m_pict.GetImageSize());
CRect rc;
rc.IntersectRect(&rcImage, &rcClient);
m_pict.Render(&dc, rc);
}
}
BOOL CPictureSSL::Render(CDC* pDC, CRect rc, LPCRECT prcMFBounds) const
{
ASSERT(pDC);
if (rc.IsRectNull()) {
CSize sz = GetImageSize(pDC);
rc.right = sz.cx;
rc.bottom = sz.cy;
}
long hmWidth,hmHeight;
GetHIMETRICSize(hmWidth, hmHeight);
m_spIPicture->Render(*pDC, rc.left, rc.top, rc.Width(), rc.Height(),
0, hmHeight, hmWidth, -hmHeight, prcMFBounds);
return TRUE;
}
This all works fine, my question is: How can I get the CPictureSSL::Render function to paint a specified colour as transparent? I though if I did m_spIPicture->Render() to a different DC I could then do the necessary bit blits to get the right effect, but I don't know enough to make it work. Any ideas?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
can i write a games like tetris or pacman using MFC or do i have to write it in windows API using C????
|
|
|
|
|
You can use MFC. You'd be better to use DirectDraw than GDI, and there's not much POINT in using MFC if your program is going to mainly be worried about drawing your game, but there is no reason you can't do so if you desire.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
There is an sample code in CP,I thing it was in DirectX or OpenGL part,its tetris game.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
How do i set it so that i enter a number in one edit box and then have it add to or subtract from a read-only. I am trying to write a program for a class that is sort of like a jeopardy game with questions and answers and i cant get the score keeper to work.
Please E-mail me
|
|
|
|
|
Use GetWindowText to get the string, atoi to turn it into a number, ostringstream or sprintf (yuck) to convert back into a string and SetWindowText to put it back into an edit box.
If you bothered to set up an account, you'd GET an email when someone replied to your post.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Is there a trick to get the function SetViewportOrgEx to work with a metafile? I am creating a metafile in memory (MapMode is MM_ANISOTROPIC), then I am loading metafiles (WMF) off disk an using PlayMetaFile to play the loaded metafile into the new metafile (I am essentially creating 1 metafile from a combination of parts for a detail drawing). The problem is I need to place the loaded metafiles in various locations however I do not seem to be able to get the xy offset to move, although I have been able to scale the images using ScaleViewportExtEx. I have tried to convert the WMF files to Enhanced metafiles (EMF) - In memory then using then using the Enhanced metafile functions - I haven't had any luck this way either.
Any suggestions?
|
|
|
|
|
I think that you actually want to use SetWindowOrgEx , this is the function that has the effect of shifting the origin.
|
|
|
|
|
I read an Nov. 2001 interview of Stanley Lippman, the VC++ architect, that mentioned future support for Winforms along the lines of C#/VB (RAD).
I further read an Feb. 2002 interview of Nick Hodapp, the VC++ proj. mgr., that (ominously in my view) did not seem to specifically mention support for Winforms/IDE/RAD/C++.
Does anyone (Chris Maunder?) have any idea how MS plans to move forward on this topic?
|
|
|
|