|
Is experimented with both on the heap and on the stact to pass a __stdcall (WNDPROC) to different functions. But the program (and explorer.exe!) crashes when I do so. Does anyone know how to safely pass a CALLBACK through a function.
eg:
WNDPROC xproc;
LRESULT CALLBACK WindowProc(...)
{
}
void a()
{
b((WNDPROC)WindowProc)
}
void b(WNDPROC wndproc)
{
// Do something like:
xproc = wndproc;
c();
}
void c()
{
SetWindowLong(hWnd, GWL_WNDPROC, (long)xproc);
}
Don't try this!
Thanks in advance,
Sjoerd van Leent
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
There are a couple of issues in your code (maybe they are due to the fact that you have deleted some stuff in your post):- The right signature for
WindowProc is
LRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
WindowProc should return a value. Also, typically you will forward most calls to DefWindowProc :
LRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
return DefWindowProc(hwnd,uMsg,wParam,lParam);
} Apart from this, the code seems just fine.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That was indeed for easyness sake
Sjoerd
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
Guys:
I need to test the existence of a file on Novell server. I could use _access() function. But, under some conditions (example: when the Novell Server is in the process of shut-down), the _access() function takes very long time to return to the caller.
So, what I need is a scheme which will enable me testing the existence of a file asynchronously.
The Async version of access() should check the file existence and notify the caller once it is done with the file check.
Thanks in advance.
|
|
|
|
|
Try using CreateFile in FILE_FLAG_OVERLAPPED mode (this probably will work only in NT/2k/XP systems.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Not sure whether I should post this in the VC++ section or XML, but since I request code, VC++ seemed the best place to me.
I'm searching for a piece of sourcecode that will convert RTF data to XML. Preferrably plain C++, not using MFC or anything else. Any hints on how to do this would be just as great.
The goal is to save a piece of RTF formatted data between a single XML tag.
--
Alex Marbus
www.marbus.net
But then again, I could be wrong.
|
|
|
|
|
Hi Alex,
I've just downloaded and tried IRun RTF Converter 1.11. It comes with an utility program that seems to work just fine. Also, it provides a .DLL you can use in your apps (not exactly source code, but it's probably the next best thing.) The whole thing is freeware.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks Joaquín.
The main issue is that is really must be platform independent (thus, standard C++). However, I read on the website (http://www.pilotltd.com/irun/) that the sourcecode is available on request. I think I might contact them (unless somebody else knows a better solution?)
--
Alex Marbus
www.marbus.net
But then again, I could be wrong.
|
|
|
|
|
i want to execute an *.mdb file by my cpp program...
does anyone know how to do this???
thanx for all answers...
|
|
|
|
|
Ok, first of all *.mdb files are not executables!
But I think what you want to do is open the mdb file
in Access ?? Is that right ?
If so you can use
ShellExecute(..) ;
with lpOperation as "open".
|
|
|
|
|
Hi all,
I'm suffering a major resource leak on Win95/98/Me in one of my drawing routines.
I realise that before an object is destroyed one must ensure it is not selected in the device context by selecting the old object beforehand.
However where my knowledge is lacking is with the use of multiple pens:
For example suppose I have a red and a blue pen.
Currently I store the old pen when selecting the red.
I then use the red pen.
Next I select the blue pen, ignoring the returned pen.
After using the blue pen, before exiting I reselect the old pen (stored when selecting the red)
I then call DestroyObject for both the red and blue pens.
Is this sufficient or must I store the oldpen each time and restore it before selecting a new one? Surely not?!
This leak is driving me insane! I know the leak is in this function because if I remove the call no crash occurs. However I cannot for the life of me see the leak! I've tried using the example here on CP to Save and Restore the DC state before and after drawing, without success.
Thanks
--
The Obliterator
|
|
|
|
|
If you are using MFC, every thing is taken care of if all the
objects are local objects.
But if you are programming in SDK you need to make calls
to DeleteObject with the resource handle.
|
|
|
|
|
I'm using MFC - and all is definitely not taken care of!
Anyhow it looks like I've finally found the leak - I'll be testing on Win9x tomorrow to be sure!
There was a pen constructed inside an if statement then selected. The old pen should have been reselected before leaving the if statement. As it was not I'm guessing the pen could not be correctly destroyed as its scope was lost.
Thanks anyhow.
--
The Obliterator
|
|
|
|
|
|
Wouldn't you have thought it could assert in the destructor if selected in the DC???
--
The Obliterator
|
|
|
|
|
Check your knowledge on DC b4 replying..
Sudip
Stupidity Sucks
|
|
|
|
|
Hello all,
I'd like ot copy from the screen to a bitmap. I have an MDI application that opens DIBs. After I open one, I'd like to get this DIB from the screen as a new bitmap in a new window.
I read the VC++ 6.0 Bible and they said just do this
void CDisplayDIBView::GetImage(int x, int y, CDC *pDC, CBitmap *pBitmap)
{
BITMAP bm;
pBitmap->GetObject( sizeof(BITMAP), &bm);
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap *pOldBitmap = MemDC.SelectObject(pBitmap);
MemDC.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, pDC, x, y, SRCCOPY);
MemDC.SelectObject(pOldBitmap);
}
Well when I do this, I get an error saying the instruction at
0x5f47c360 referenced memory at 0x000000e. The memory could not be "read."
How would I go about correcting this, or accomplishing what I want to do?
Thanks a whole lot,
NickOne
|
|
|
|
|
NickOne wrote:
Well when I do this, I get an error
which line gives you the error?
is pDC valid?
is pBitmap non-NULL?
-c
Being just contaminates the void. --Robyn Hitchcock
|
|
|
|
|
First make sure that your bitmap is not larger than your screen or the offset that you passed
(x,y) are not playing against you. Make sure your bitmap object is not null or too small.
Maybe you need to call CreateCompatibleBitmap(...) with your bitmap object.
Good luck!
Last Article:
Adding VBScript/JScript to C++ App
|
|
|
|
|
Hello everyone!
Does anyone knows how tu use the system tray ?
Thanks for your answers
|
|
|
|
|
If you refer to system tray icons, Chris Maunder's Adding Icons to the System Tray will probably cover all of your needs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
yaa it is easy
NOTIFYICONDATA gl_sNotifyIconData;
gl_sNotifyIconData.cbSize=sizeof(NOTIFYICONDATA);
strcpy(gl_sNotifyIconData.szTip,"your Tool tip here");
gl_sNotifyIconData.uID=FTPTRAYID;
gl_sNotifyIconData.hIcon=AfxGetApp()->LoadIcon(ID of ur tray ICON);
gl_sNotifyIconData.uCallbackMessage=the Message ID of ur app here;
gl_sNotifyIconData.hWnd=this->m_hWnd;
gl_sNotifyIconData.uFlags=NIF_ICON|NIF_MESSAGE|NIF_TIP;
Shell_NotifyIcon(NIM_ADD,&gl_sNotifyIconData);
this will put the icon in to your system tray
and everythime u enter mouse over it it post some messages
so it is necessery to trap the message
by adding the ON_MESSAGE(messageID,onmessage) in your messagemap
and add a function like
onmessage(WPARAM wparam,LPARAM lparam)
{
wparam contains the trayID
and lparam caontains the message
handle them according to ur need
}
Renjith-CPian.
|
|
|
|
|
Hello
How can you make a dialog that doesn't take the control of the application (wait for the answer of DoModal)like the tool windows of psp for example...
|
|
|
|
|
These are called modeless dialogs. Search for these words on your documentation.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|