|
Maybe it would help a lot if you describe exactly what you want to achieve. In general, reading and writing to a serial port can be done by several ways (specifically for reading). You can use a loop with timeouts (in a separate thread for example), ...
But if you want to really respond when there is an interuption, then you'll need to go for a device driver (and I suppose it must be tricky to do).
Anyway, even inside your driver, you will still have the problems of the real-time behavior, which is that Windows is not a real time operating system, so everything you want to achieve under the resolution of 10 msec (it can vary) is unfeasible.
|
|
|
|
|
If you want to be notified on receipt of a char, you can use overlapped I/O with your read. That way an Event will be signalled any time you receive a character.
You could put a receive loop in a separate thread, anf then post each characted received with a resgistered window message.
The choices may not be endless, but they are several!
Iain.
|
|
|
|
|
Ok, for rage, yes it was 5 p.m.
I know the way ReadFile Overlapped IO etc.
I was asking myself if there was a way of control interrupt the way dos/microcontroller do
I think the only suitable way is creating a device driver
It's better if re-study behavior of ReadFile,Events and Overlapped IO
Thanks to all
|
|
|
|
|
Hi fellows. I'm developing a program that returns the hwnd of all opened windows in the desktop. The problem is that function always returns 2 hwnd ID's. Can someone helps in this??
Thanks a lot...
void OpenedWindows(HWND hwnd)
{
HWND childWindow;
//is child of the desktop window???
if((childWindow = GetWindow(hwnd, GW_CHILD)) != NULL)
{
if(childWindow != NULL)
{
MessageBox(NULL, itoa(((int)childWindow), cVal, 10), "Is Child", MB_OK);
OpenedWindows(childWindow);
}
else
{
MessageBox(NULL, "No window child!!", "No Child", MB_OK);
}
}
else //Catch the next's window
{
childWindow = GetNextWindow(GetParent(hwnd), GW_HWNDNEXT);
if(childWindow != NULL)
{
MessageBox(NULL, itoa(((int)childWindow), cVal, 10), "Do Else", MB_OK);
OpenedWindows(childWindow);
}
else MessageBox(NULL, "Is NULL", "", MB_OK);
}
}
|
|
|
|
|
void OpenedWindows(HWND hwnd)
{
HWND childWindow;
if((childWindow = GetWindow(hwnd, GW_CHILD)) != NULL)
{
if (childWindow != NULL)
{
MessageBox(NULL, itoa(((int)childWindow), cVal, 10), "Is Child", MB_OK);
OpenedWindows(childWindow);
}
else
{
MessageBox(NULL, "No window child!!", "No Child", MB_OK);
}
}
else
{
childWindow = GetNextWindow(GetParent(hwnd), GW_HWNDNEXT);
if(childWindow != NULL)
{
MessageBox(NULL, itoa(((int)childWindow), cVal, 10), "Do Else", MB_OK);
OpenedWindows(childWindow);
}
else MessageBox(NULL, "Is NULL", "", MB_OK);
}
}
Why Getparent and not simply hwnd.
But anyway, I would not use clumsy recursion on the Z-order, but use GetDesktopWindow followed by EnumChildWindows , much more reliable IMO.
~RaGE();
|
|
|
|
|
Hi all
can any one tell me how to retreive the attributes of a paticular node in a Tree Structure which is derived from CTreeCtrl ,if i know the handle of that particular node ,in MFC
|
|
|
|
|
Use the GetItem() method.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
but what is the parameter for this GetItem( ) method
i ve Tree Structure as below
-Loop
-Slab=1
Slice=1
Slice =2
-slab=2
slice=1
slice=2
i want to explore all the items in a messageBox
( from Loop to slice=2)
for that one my code will be look like
for(i=0;i<(ptrTree->GetCount()); i++)
-- modified at 9:43 Monday 30th January, 2006
|
|
|
|
|
A pointer on a TVITEM structure. Here you go:
typedef struct tagTVITEM{
UINT mask;
HTREEITEM hItem;
UINT state;
UINT stateMask;
LPTSTR pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
LPARAM lParam;
} TVITEM, FAR *LPTVITEM;
See MSDN for more info.
Typical code snippet:
TVITEM tvi;
ZeroMemory(&tvi,sizeof(tvi));
tvi.hItem = YourItemId;
tvi.mask = TVIF_TEXT |TVIF_STATE;
m_TreeCtrl.GetItem(&tvi);
// Now tvi is fulled with the item's attributes.
~RaGE();
|
|
|
|
|
Thanku rage
but i m getting an error of
GetItem cannot convert parameter 1 from 'struct myClass::MyFunction:tagTVITEM *' to 'struct tagTVITEMA *'
|
|
|
|
|
Can you post the part of the code where you are doing the call ? Are you using MFC ?
~RaGE();
|
|
|
|
|
You've erroneously made tagTVITEM part of your class, which is unnecessary.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Good point David, I missed the myClass::MyFunction . He must have misinterpreted my thread and define the TVITEM I gave as an example. Never give too much information
~RaGE();
|
|
|
|
|
kandukuri wrote:
but what is the parameter for this GetItem( ) method
A pointer to a TVITEM structure.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hi,
I am trying to do TDI hook driver, I just need to get notification, something like sysinternals.com TDIMon does.
I have no problem to get most of the TDI IRPs but
TDI_ACCEPT or TDI_SEND I never got..
Does anyone know what I am doing wrong?
What is special on this IRPs?
Thanx for help
viliam
|
|
|
|
|
You have implemented a filter driver on top of \Device\Tcp ? If you are on the top of the device stack you will get all the IRPs there is no special handling of those particular IRPs unless you are doing something different than I beleive you to be doing.
What Application are you attempting to filter that is not working correctly, have you verified that TDIMon is working correctly in the same situation? Also, there is a seperate device used by sockets which is \Device\Afd which I believe has a different interface than TDI. I believe there is an open source project which is a firewall that filters this interface for which you may be able to review (It also filters TDI) to find out this interface. I believe it is on sourceforge.
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
Hi all,
I have created a (very simple) bitmap editing program with a dialog based MFC project. Everything seems in order so far but I don't know how to save the HBITMAPs that I have created to file. I have tried using snippets of code from other examples but to no avail.
Any help would be much appreciated
|
|
|
|
|
Is it not possible to serialize your bitmap ? Create a CBitmap from your handle HBITMAP using CBitmap::FromHandle , then Serialize it.
~RaGE();
|
|
|
|
|
If it is a DDB(device dependent bitmap) use GetDIBits(...) on the HBITMAP and get the
DIB with the format of your choice specified via the BITMAPINFO. Once got the DIB bits,
you can save to the file by putting the BITMAPFILEHEADER,BITMAPINFO and the bits itself
to a file in that sequence.
Vipin - MVP
|
|
|
|
|
|
hi,
strange problem with my colors: i want to display a tray icon but it always appears in black & white although the image HAS color. I've tried it with a 256 color bitmap, a 256 color icon, a 24 Bit color bitmap and a 24 Bit color icon (every variant with 16x16 Pixel) each time the same effect - JUST BLACK AND WHITE. Even with different functions for loading the images hasn't changed it. (tried LoadIcon, LoadImage and CreateIconIndirect )
any ideas what this may trigger ?
greets
|
|
|
|
|
Unless you're using Windows XP, tray icons always render using the standard 16 system colours, so you'll need to provide a 16 colour icon to stop it trying to convert it for you (which usually looks awful)
On XP, it renders the icons properly, using all available colours
--
Help me! I'm turning into a grapefruit!
Buzzwords!
|
|
|
|
|
you're right - windows converts my icon into 16 colors. but how do i can make sure to use only the standard 16 system colors ?
|
|
|
|
|
The simplest way is to copy your existing icon, add a new 16 colour icon to the resource in visual studio, and paste in your icon. This will create a 16 colour icon which you can then manually edit until it looks good enough (you can often redraw the icon yourself far better than windows will do itself when it remaps the icon at runtime)
--
Help me! I'm turning into a grapefruit!
Buzzwords!
|
|
|
|
|
hm, although i hoped that i didn't have to redraw the icon by my self it's seems there leads no way around.
16 colors are ridiculous however,
thanks anyway.
|
|
|
|