|
Does anybody know where I can find ROP code table.
|
|
|
|
|
HI
I’m confused between pointer to CWnd and handle also to CWnd .What’s the difference between handle and pointer in CWnd object .For example when I want to chat text color in text box control :
HBRUSH CMyDlg::OnCtlColor(CDC*pDC,CWnd*pWnd,UINTCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
//////////////////////////////////////////////
CWnd* wnd=GetDlgItem(IDC_EDIT1);
if(wnd==pWnd) // using pointers
{
pDC->SetTextColor(RGB(255,0,0));
}
///////////////////////////////////////////////
return hbr;
}
this code doesn’t chang text color .But when I use handles like this example :
HBRUSH CMyDlg::OnCtlColor(CDC*pDC,CWnd*pWnd,UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
////////////////////////////////////////////////
CWnd* wnd=GetDlgItem(IDC_EDIT1);
if(wnd->m_hWnd==pWnd->m_hWnd) // using handles
{
pDC->SetTextColor(RGB(255,0,0));
}
///////////////////////////////////////////////////
return hbr;
}
now this code do what I want to chang text color .
Can any one tell me what difference between pointers and handles in CWnd objects ?
Thank you …
AHMAD ALWASHALI
|
|
|
|
|
I believe that a pointer is an actual object (CWnd for example) and a handle is the location in memory of that object (or object referenced by the pointer). So say you have a window in memory and you want to access the methods/properties of that window...you would have a pointer/object that "attaches" itself to the window at that memory location thereby giving you access to its "structure and methods". Hope that helps.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Handle to a window (HWND) is a Win32 animal - it's a magic cookie which is used to identify windows in the system. Ok, it's not exactly magic: HWND is just a 32-bit number without meaning outside of running Windows system.
MFC is a C++ library, and represents windows as C++ objects derived from class CWnd. Each CWnd-derived object has a data member, m_hWnd, which holds the corresponding Win32 HWND. But the connection between HWNDs and CWnd pointers doesn't stop here: MFC also uses handle maps to provide C++ pointers to CWnd-derived objects when it's needed. In your example, OnCtlColor function receives C++ pointer to a CWnd. Before calling your handler, MFC checks if there's already some CWnd object, if not it creates temporary one and passes its address instead of HWND.
Actually, the mapping is somewhat more complicated: there are 'permanent' and 'temporary' maps, I believe this could be the source of your problems.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
|
In general, a handle is just a 32-bit key to a data structure maintained by Windows. Some common handles are:- HACCEL - Handle to an accelerator table.
- HANDLE - Handle to an object.
- HBITMAP - Handle to a bitmap.
- HBRUSH - Handle to a brush.
- HCOLORSPACE - Handle to a logical color space.
- HCONV - Handle to a dynamic data exchange (DDE) conversation.
- HCONVLIST - Handle to a DDE conversation list.
- HCURSOR - Handle to a cursor.
- HDC - Handle to a device context (DC).
- HDDEDATA - Handle to DDE data.
- HDESK - Handle to a desktop.
- HDROP - Handle to an internal drop structure.
- HDWP - Handle to a deferred window position structure.
- HENHMETAFILE - Handle to an enhanced metafile.
- HFILE - Handle to a file opened byOpenFile, notCreateFile.
- HFONT - Handle to a font.
- HGDIOBJ - Handle to a GDI object.
- HGLOBAL - Handle to a global memory block.
- HHOOK - Handle to a hook.
- HICON - Handle to an icon.
- HIMAGELIST - Handle to an image list.
- HIMC - Handle to input context.
- HINSTANCE - Handle to an instance.
- HKEY - Handle to a registry key.
- HKL - Handle to a keyboard layout.
- HLOCAL - Handle to a local memory block.
- HMENU - Handle to a menu.
- HMETAFILE - Handle to a metafile.
- HMODULE - Handle to a module.
- HMONITOR - Handle to a display monitor.
- HOOKPROC - Pointer to an application-defined hook function specified toSetWindowsHookEx.
- HPALETTE - Handle to a palette.
- HPEN - Handle to a pen.
- HRGN - Handle to a region.
- HRSRC - Handle to a resource.
- HSZ - Handle to a DDE string.
- HTREEITEM - Handle to an item in a tree-view control.
- HWINSTA - Handle to a window station.
- HWND - Handle to a window.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
HI
I use (Microsoft FlexGrid Control, version 6.0) which is active x control .It’s very useful, but some member functions are unclear .
Now I’m interested in how useing three functions and maybe they will be the keys of the rest functions .
1 – void AddItem(LPCTSTR Item, const VARIANT& index)
to add new rwo BUT HOW???
2 - long GetRowData(long index)
to get data from specific row BUT HOW???
3- How can I get data from multi row selection ?
Thank you very much …
AHMAD ALWASHALI
|
|
|
|
|
Read the help file, boy. It is the file
c:\Winnt\Help\MsFlxGrd.hlp
or
c:\Windows\Help\MsFlxGrd.hlp
|
|
|
|
|
Hello,
I have a dialog type app, I use a minimize to system tray class that puts the icon to the system tray.. When I close the app the icon is still visible until I pass the mouse over it, then it goes away.. What's the best way to kill the app so it removes all traces from the system.. Right now I just do a OnOK();
Rob
|
|
|
|
|
Can you please tell more on how you close the app while it's in minimized state? (sending a message from somewhere else?)
Generally speaking, there are a few SDK functions that are used to terminate Win32 apps explicitly.
(1) ::TerminateProcess(HANDLE hProc);
(2) ::PostQuitMessage(WM_QUIT);
See MSDN documentation to find more..
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
The system tray icon will hang around until you remove/destroy it. When your app exits, you should remove/destroy the systray icon.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
When I close the app the icon is still visible until I pass the mouse over it,
That's because you're not calling Shell_NotifyIcon() to remove the tray icon before your app exits.
--Mike--
http://home.inreach.com/mdunn/
"The Earth is doomed." -- Rupert Giles
your with and
|
|
|
|
|
I feel dumb ... that worked like a charm.
Thanks!
Rob
|
|
|
|
|
I was wondering, is there a way to wait for a single process to complete with out using treads? I am reading data from a serial port at a low baud rate, and before the read is complete my program cuts it off and starts processing the data. Any help is appreciated.
Thanks.
|
|
|
|
|
I'm not sure what do you mean by 'process' in your post. Is that just some activity of your program, like reading from serial port, or OS object created with a call to CreateProcess?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
What I mean by process is the read... When I do my read call, before the read has finished reading all the data it is supposed to, my program is already trying to use that data... this results in data being lost or corrupted. Is there anyway to wait for the read to finish and then when it is done, continue the program?
|
|
|
|
|
Is there anyway to wait for the read to finish and then when it is done, continue the program?
How do you read the bytes from the serial port?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I connected to the serial port like this...
hCommPort = CreateFile( "COM1",GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
then I read like this...
ReadFile (hCommPort, buffer, 8, &dwBytesTransferred, NULL);
|
|
|
|
|
So ReadFile returns an error and exits prematurely? You're not using overlapped I/O - there's no FILE_FLAG_OVERLAPPED flag in the call to CreateFile.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
No, there is not an error... It just reads and continues, but the read is not finished when it goes on... I have put a Sleep(500) after the read, and it then works correctly, but I know that this is not a good approach.
|
|
|
|
|
|
Yes, that is correct. It is sometimes 8, and sometimes less. Also when it is less than 8 there is sometimes garbage symbols there as well.
|
|
|
|
|
|
That's ok, thanks for your time.
|
|
|
|
|
I think I understand the problem...
You are getting all the bytes available at the time of the call, up to the requested MAXIMUM. Put the read in a loop, with a Sleep. It doesn't have to be long... Keep looping until you have read all the bytes you want.
Bill
|
|
|
|