|
I'm trying to cover my tracks and for every function that
draws to some CDC I do do a SaveDC and RestoreDC before actually
selecting any GDI Objects into it. But I'll double check to see
if something slipped by me.
Much Thx,
-t²
|
|
|
|
|
Also check device contexts being destroyed - this also applies to memory DCs.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
BeginPaint(&PAINTSTRUCT) and EndPaint(&PAINTSTRUCT) should cover
that right?
This isn't my whole OnPaint() function, but it should cover important
issues.
PAINTSTRUCT ps;
CPaintDC *paintDC;
paintDC = (CPaintDC *)this->BeginPaint(&ps);
paintDC->StretchBlt(m_rectHead0.left, m_rectHead0.top,
m_rectHead0.Width(), m_rectHead0.Height(),
m_dcHead0,
m_rectHead0Source.left, m_rectHead0Source.top,
m_rectHead0Source.Width(), m_rectHead0Source.Height(),
SRCCOPY);
this->EndPaint(&ps);
-t²
|
|
|
|
|
You don't need this SDK-style stuff. I'm not sure if this has something to do with your problems, but you can just declare CPaintDC and use it inside OnPaint. No need to play with BeginPaint and EndPaint; CPainDC does this for you.
Also, you don't need to use this->GetDC and this->ReleaseDC. Just declare a CClientDC variable.
And why on earth are you using 'this->'? Do you come from JavaLand?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I've created an ATL COM - dll - MFC Supported with the AppWizard and I added a function that return a CString.
Now I want access to this function from another application to do it I type the next code.
In the ATL COM
...
__declspec(dllexport) CString GetEncodedText(CString p_sPlainText);
...
In the other application
...
hDLL = AfxLoadLibrary("BabMD5.dll");
if (hDLL != NULL) {
typedef CString (CALLBACK *ENCODETEXT)(CString);
ENCODETEXT p_encodeText = (ENCODETEXT)GetProcAddress( hDLL, _T("GetEncodedText"));
if ( p_encodeText != NULL) { // -> NEVER GET HERE
strEncoded = (*p_encodeText)( strPlain );
}
AfxFreeLibrary( hDLL);
}
...
Anybody knows what's happen? Why I can't get the function?
Thanks in advance
|
|
|
|
|
Why are you using a C export function in a COM DLL? It would make more sense to create an interface which has GetEncodedText as a method.
HRESULT CTest::GetEncodedText(BSTR PlainText, BSTR* EncodeText)
Michael
|
|
|
|
|
You are right, but this is my first adventure with COM and then I don't know how to access to the method through the other application
|
|
|
|
|
If you wrote a ATL/COM Object, Only you need to Import the Dll functions...
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Don't mix standard DLL exports with In-Proc (DLL) COM Servers.
It won't work !!!!
|
|
|
|
|
The source code shown below is a simple, working wav file player application. The program work perfectly under Windows 2000, but fails in a repeatable fashion under Windows 98.
Let me briefly describe the functionality, then describe a mode of operation that works properly under both OS'es, then a mode of operation that fails only under Windows 98.
When the program is started, the wav memory structures are initialized (WM_CREATE calls CreatePlayer). When a file is to be played, Play() is called. This routine opens the file "test.wav" (a 44.1 kHz sampled, stereo file), prepares the headers and fills the first set of buffers. As the wav device renders each buffer, it send a MM_WOM_DONE message to its callback routine. This routine sends a WM_COMMAND message to the main program, which then calls ReadBuffer() to refill the just-emptied buffer. When there is no more data to be read from the file, ReadBuffer() returns a 1, signaling the main program that the file has been completely rendered. The main program then sends a Stop(), which closes the wav device. Note that Stop() does not free any memory as Play() can be called again.
Under both OS'es, if the a file is Play()'ed then Stop()'ed, it can be Play()'ed again without any problems. This is as expected.
Under Win2k, if a file is allowed to Play() to completion, clicking Play() again causes the file to be Play()'ed. This is as expected. However, under Win98, when a file is allowed to Play() to completion, clicking Play() results in waveOutPrepareHeader() returning with an error, MMSYSERR_NOMEM, and the file does not Play().
I have tried a number of ways to solve this problem, including using memory locking, freeing and reallocating memory each time the player Stop()'s, etc. I haven't a clue as to why this is failing in this manner. Your thoughts and suggestions are gratefully accepted!
=== source code ===
#include <windows.h>
#include <winuser.h>
#include <mmsystem.h>
#include <stdio.h>
#define NBUFS_OUT 4L
#define OUTBUFSIZE 0x4000L
#define ID_DONEBUFFER 40000
#define ID_CLOSED 40001
#define ID_PLAY_BUT 40002
#define ID_STOP_BUT 40003
#define WAVE_PLAYING 1
#define WAVE_READY 2
long doneBufCnt = 0;
FILE *fp = NULL;
HWND hWnd = NULL;
HWAVEOUT hWaveOutDevice;
WAVEFORMATEX waveOutFormatEx;
WAVEHDR waveOutHdrs[NBUFS_OUT];
HINSTANCE myhInstance;
///////////////////////////////////////////////////////////////////////////////
void CALLBACK WaveOutCallback (HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
///////////////////////////////////////////////////////////////////////////////
{
switch (uMsg)
{
case MM_WOM_OPEN: // device opened via waveOutOpen(), nothing to do
break;
case MM_WOM_DONE: // device done playing data sent via waveOutWrite()
SendNotifyMessage (hWnd, WM_COMMAND, ID_DONEBUFFER, ((WAVEHDR *)dwParam1)->dwUser);
break;
case MM_WOM_CLOSE: // device closed via waveOutClose()
SendNotifyMessage (hWnd, WM_COMMAND, ID_CLOSED, 0L);
break;
}
}
///////////////////////////////////////////////////////////////////////////////
long ReadBuffer (long curBuf)
///////////////////////////////////////////////////////////////////////////////
{
if ((waveOutHdrs[curBuf].dwBufferLength = fread (waveOutHdrs[curBuf].lpData, 1, OUTBUFSIZE, fp)) != OUTBUFSIZE)
{
if (feof (fp))
doneBufCnt++;
}
else
waveOutWrite (hWaveOutDevice, &waveOutHdrs[curBuf], sizeof (WAVEHDR));
if (doneBufCnt == NBUFS_OUT)
{
doneBufCnt = 0;
return 1;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
void CreatePlayer (void)
///////////////////////////////////////////////////////////////////////////////
{
long myInt;
fp = fopen ("test.wav", "rb");
waveOutFormatEx.wFormatTag = WAVE_FORMAT_PCM;
waveOutFormatEx.nChannels = 2;
waveOutFormatEx.nSamplesPerSec = 44100;
waveOutFormatEx.nAvgBytesPerSec = 176400;
waveOutFormatEx.nBlockAlign = 4;
waveOutFormatEx.wBitsPerSample = 16;
waveOutFormatEx.cbSize = (WORD)0;
for (myInt = 0; myInt < NBUFS_OUT; ++myInt) {
memset (&waveOutHdrs[myInt], 0, sizeof (WAVEHDR));
waveOutHdrs[myInt].lpData = (char *)calloc (OUTBUFSIZE, sizeof(char));
waveOutHdrs[myInt].dwUser = myInt;
waveOutHdrs[myInt].dwBufferLength = OUTBUFSIZE;
}
}
/////////////////////////////////////////////////////////////////////////
void Play (void)
///////////////////////////////////////////////////////////////////////////////
{
long myInt;
DWORD dwInstance = 0;
fseek (fp, 44, SEEK_SET);
waveOutOpen ((LPHWAVEOUT)&hWaveOutDevice, WAVE_MAPPER, &waveOutFormatEx, (DWORD)WaveOutCallback, dwInstance, CALLBACK_FUNCTION);
waveOutPause (hWaveOutDevice);
for (myInt=0; myInt
|
|
|
|
|
Is there a better (faster) way to load/reload/refresh a report type of CList than looping the Recordset and adding the items. When the recordset is large, it seems to take a long time to fill the CList.
Here's what I'm doing now:
m_pSet->MoveFirst();
while (!m_pSet->IsEOF)
{
Add Items to the CList here
}
m_pSet->MoveNext();
Thanks!
Richard
|
|
|
|
|
How many items are you putting into the CListCtrl? Too many and CListCtrl does slow down. Does it make any difference if you load the data into a collection class first and fill the listctrl from the collection?
Michael
|
|
|
|
|
C'mon Michael - do you really think that putting data into std::something or CxxxArray first, then copying everything into CListCtrl will help?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I dunno. It was a pretty dumb suggestion now I think about it. He has emailed me since that there are several thousand entries. Obviously a list control isn't designed for that number of records at once. Who'd want to look through so many records? Putting into a collection class will at least mean he can load 200 records, display them, load the next 200 into the collection and display them when needed.
Michael
|
|
|
|
|
I think it should work with few thousand items without much problems. But it would be helpful to call SetRedraw(FALSE) before inserting data into control and SetRedraw(TRUE) afterwards.
Storing data in a collection makes sense when you're using owner-data list control.
Anyway, I probably should write that under original post
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
use the virtual database list idea
see
http://www.codeguru.com/mfc_database/virtual_dblist.shtml
Its seems to have the answer you want
|
|
|
|
|
I need to know what browser is the default browser and in what directory is located, so I can call ShellExecute to open some html pages but NOT in the same window. So I guess this information must be stored into the registry, right? So in what keys?
|
|
|
|
|
How do you want to force opening .html in new window? Are there any commandline switches you're going to pass to ShellExecute?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I'm gonna say instead of ShellExecute(..,"open","page.html",...) wich opens the pages in same windows. ShellExecute(..,"open", "Path_got_from_registry:\\iexplore.exe page.html",...). It opens the pages in separate windows. That I know!
|
|
|
|
|
|
There is no such parameter as openew to pass to ShellExecute. It's not a smart builed function if u ask me!
|
|
|
|
|
There is no such parameter as openew to pass to ShellExecute.
You're passing plain string as a verb to ShellExecute. 'opennew' is registered as a .html verb, at least on my W2K machine.
It's not a smart builed function if u ask me!
Sure. Microsoft should hire you as a consultant.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
|
Call
RegQueryValueEx(...)
with
HKEY_CLASSES_ROOT,
"http\\shell\\open\\command",
"(Default)"
and you should get the path to the application browser running as default.
/Tommy
|
|
|
|
|
debug version with execute works fine
debug version with debug/run crashes at start
what can be reason?
thanks for ideas
t!
|
|
|
|