|
Well don't eat ALL the keyboard messages
|
|
|
|
|
I've researched the matter today; studied the Visual Studio documentation; but couldn't make it work.
It seems that SetWindowsHookEx() uses a callback function KeyboardProc(). But I found the documentation too confuse, and did not find any example code to help.
Maybe it is just the Friday effect, or the effect of all those Christmas foods, but I just couldn't understand it.
So, I would really appreciate more help.
Thanks!
PCFilho
Rio de Janeiro, Brazil
|
|
|
|
|
I haven't written a keyboard hook so I have no code I can post but a quick search yielded
this article[^] and this article[^]
These should be helpful. Basically once you've installed the hook, in your hook proc you'll
need to look at the key code and if you want to eat the code, return TRUE, otherwise call the
next proc in the hook chain to let the message get processed as usual.
As others have noted, you won't be able to trap ctrl-alt-delete...the first article link above
explains this a bit
Mark
|
|
|
|
|
Thank you, Mark.
These articles are helping me very much...
King regards,
PCFilho
Rio de Janeiro, Brazil
|
|
|
|
|
hi, happy new year. i'm having a problem with some open source frameworks, and i think it's a compiler problem. when i compiled the FOX toolkit (www.fox-toolkit.org) using the bundled VC++ solution, i configure the build by adding some external libraries (namely zlib, bzip2, libpng, jpeglib, and libtiff), by defining some constants (as suggested in the instructions). here's where the problem is: the library built fine, but when i tried building one of the examples, the linker gave errors about the C runtime library already linked in, and multiply defined symbols. i've had this problem before (after building wxWdigets and using it for an application), and i had to delete the project, rebuild the libray and recode the application. i'd rather not fluke fixing the problem. how can i fix this o i know exactly what to do everytime the problem comes up? thanks.
|
|
|
|
|
I use
EnumChildWindows();
for get "handle" of control in target window.
then I want to use IsKindof() function that is member of CWnd for check it is CEdit object or not.
Can I do like this?
|
|
|
|
|
Use CWnd::Attach() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Heh - you answered his subject, but that will not work for what he really wants to do as specified in his message.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
You can associate a HWND with a CWnd object using CWnd::Attach() BUT...
IsKindOf() works with object types so I don't think this will work for you.
You could use GetClassInfoEx() and examine the WNDCLASSEX lpszClassName member to find the
window's type.
Mark
|
|
|
|
|
That will not work correctly, at least not the way you would want it to.
You can pass the HWND to the ::GetClassName(...) function. Look up that function for more info on how to use it.
If the control is a standard Edit control, the returned class name will be EDIT . Lookup the predefined window classes for more info.
You could also check by sending the window a edit-control-specific message and see if the response you get back makes sense.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
::GetClassName()!! I knew it existed but I swear I couldn't find it.
If only Microsoft used a more appropriate name for the API
|
|
|
|
|
Look up CWnd::Attach , CWnd::FromHandle and CWnd::FromHandlePermanent . Which you use depends on your situation.
Steve
|
|
|
|
|
You can use of CWnd::FromHandle
and From the MSDN:
"If a CWnd object is not attached to the handle,a temporary CWnd object is created and attached"
|
|
|
|
|
Max++ wrote: then I want to use IsKindof() function that is member of CWnd for check it is CEdit object or not
CWnd::FromHandle is one option.
Max++ wrote: function that is member of CWnd for check it is CEdit object or not.
You can achieve this without using above approach. Have a look at this code ,
static const TCHAR szEdit[] = _T("Edit");
TCHAR szCompare[256] = {0};
::GetClassName(hEdit, szCompare,256);
if (lstrcmpi(szCompare, szEdit) == 0)
{
}
|
|
|
|
|
Hi
Does anyone know how to get this behaviour to appear within a CDialog (with an editbox set with password property)?
I'm using VS2003.
|
|
|
|
|
Normally, you will get this functionality automatically [1] when running on XP (or above?) and [2] your application has a common control manifest that specifies that the new/XP common control libraries be used.
Or are you asking how you can create that behavior so that your application always does something like it, regardless of platform or manifest?
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Yes, running on XP, not too concerned about other platforms.
Here is my manifest - am I not specifying the correct libraries?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="Microsoft.Windows.TestApp"
type="win32"
/>
<description>Your app description here</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
|
|
|
|
|
That looks correct to me - do you have it in the correct location? If not embedded, it should be in an external file named the same as your executable file with .manifest appended to it.
For example, if your executable is called MyApp.exe , the manifest file should be MyApp.exe.manifest , and kept in the same directory that the executable is in.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James
Many thanks for your help. I've finally sorted it! I've added an external manifest (ensuring the language is set to English(US) in the resource properties, and as if by magic, the XP Themes are applied.
Graham
|
|
|
|
|
Hi everyone
Ive recently been tasked to add a bitmap to a listctrl, which ive done sucessfully, with a little help from Matt Weagle's excellent article (http://www.codeproject.com/listctrl/listctrldemo.asp[]
However, when text is placed over it, the text background color is white (which obviously obcures the image).
This was fine - even the demo app does this, but having passed this code to my collegue, his bitmap doesnt get obscured. We are using the same code, environment, both using Visual Studio 2003. Checked everything I can think of (project settings, resource & stdafx files etc.).
Can anyone help please?
|
|
|
|
|
What is the code you're using to place text over the bitmap?
Mark
|
|
|
|
|
Hi Mark
>Mark Salsbery wrote:
>What is the code you're using to place text over the bitmap?
Its a standard SDI app:
void MyRightView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl& ctlList = (CListCtrl&) GetListCtrl();
ModifyStyle ( LVS_TYPEMASK,LVS_REPORT);
ListView_SetExtendedListViewStyle (m_hWnd, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP);
ctlList.InsertColumn(1,"A",NULL,50,NULL);
ctlList.InsertColumn(2,"B",NULL,100,NULL);
ctlList.InsertColumn(3,"C",NULL,100,NULL);
ctlList.InsertColumn(4,"D",NULL,50,NULL);
ctlList.InsertColumn(5,"E",NULL,80,NULL);
ctlList.InsertColumn(6,"F",NULL,50,NULL);
ctlList.DeleteAllItems();
for (int f=0; f<20;f++)
DisplayLine(f);
EnableBkImage(TRUE);
}
void MyRightView::DisplayLine(int line)
{
CListCtrl& ctlList = (CListCtrl&) GetListCtrl();
ctlList.InsertItem(line,_T("12345"),0);
ctlList.SetItemText(line,1,_T("Test"));
ctlList.SetItemText(line,2,_T("A"));
ctlList.SetItemText(line,3,_T("1F"));
ctlList.SetItemText(line,4,_T("2006-12-1"));
ctlList.SetItemText(line,5,_T("AM (N)"));
ctlList.SetItemText(line,6,_T("22-12-2006"));
}
void MyRightView::EnableBkImage(BOOL bEnable)
{
CListCtrl& ctlList = (CListCtrl&) GetListCtrl();
if (bEnable)
{
// Load the resource and apply it to the background
TCHAR szBuffer[_MAX_PATH];
VERIFY(::GetModuleFileName(AfxGetInstanceHandle(), szBuffer, _MAX_PATH));
CString sPath;
sPath.Format(_T("res://%s/#2/#139"),szBuffer);
LVBKIMAGE bki;
bki.ulFlags = LVBKIF_STYLE_NORMAL | LVBKIF_SOURCE_URL ; //LVBKIF_STYLE_TILE
bki.pszImage = sPath.GetBuffer(sPath.GetLength());
bki.cchImageMax = sPath.GetLength();
bki.xOffsetPercent= 50;
bki.yOffsetPercent=50;
VERIFY(ctlList.SetBkImage( &bki));
}
else
ctlList.SetBkImage( HBITMAP(0));
}
|
|
|
|
|
Can you show your code(of course not all )
|
|
|
|
|
Hi
Mangaged to fix this - 1 line of code (strangly my collegue doesnt need to use this though )
ctlList.SetTextBkColor(CLR_NONE);
pity MSDN doesnt seem give you a list of these parameters
Thank you for your attention!
|
|
|
|
|
thefainster wrote: Mangaged to fix this
Cool
It's good practice IMO to always setup drawing the way you want it so you don't rely on behavior
between machines.
Glad you got it fixed!
Mark
|
|
|
|
|