|
Hi all,
I was wondering...
How can you give the desktop or taskbar the keyboard focus?
I know there is an SetFocus function but that only works for a window that's your app own.
Aidman » over and out
|
|
|
|
|
In the Platform SDK for SetFocus, it includes the following sentence:
By using the AttachThreadInput function, a thread can attach its input processing to another thread. This allows a thread to call SetFocus to set the keyboard focus to a window attached to another thread's message queue.
Which should help you get around the (deliberate) limitation. You could always detach straight after.
Iain.
|
|
|
|
|
But how can I get the Thread handle of the Desktop or Taskbar wich need to attach to?
Aidman » over and out
|
|
|
|
|
GetWindowThreadProcessId should give you the information you need.
Iain.
|
|
|
|
|
I tried to that, but I don't really understand how it is supposed to be done. Must I do this in a callback function or can I do it in the winman? Could you please demonstrate this process in code please?
Aidman » over and out
|
|
|
|
|
I'm using SetTimer() and KillTimer() with the simple WM_TIMER event in my CWnd application.
Given the ID number for a timer which has been set, is there a way to find out how much time is remaining before the next call for that timer?
|
|
|
|
|
No, for two reasons. 1, the timeout you pass to SetTimer() is usually not the same as the actual timeout used by the OS. The actual timeout is always a multiple of a hardware timer (about 55 ms I think on Win 9x). 2, WM_TIMER is posted to your message queue, and it's impossible to predict how much time will elapse before that message is processed.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
hi,
using the MFC, I just want to have a window in which u can chat, so with an edit control at the bottom and also a view to display a text.
and then my real problem will be to display a text on this window, I thing that I will have to use the OnPaint(), but I don't really know how to deal with that stuff.
thx for ur help.
--
Kas'pac'll be back.
|
|
|
|
|
Hello.
You can use the CFormView Class .The FormView have a look like Dialog.You can place a RichEdit control on the top of form view and place a Edit control on the bottom of form view.
Good luck!
|
|
|
|
|
Hi,
thanks for ur idea TLiu, I'll try that, but I still wonder how to do to display a text on the RichEdit control.
thx very much.
--
Kaspac'll be back.
|
|
|
|
|
You can reference to MSDN about CRichEidt.I remenber that there is a sample in MSDN about wordpad.Using CRichEdit in the sample.;)
|
|
|
|
|
ummmmm i hate to rain on ur parade man (as the man said) but theres just a little more to a chat program than an edit window and a few buttons
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
I'm working on a MDI in which I use CScrollView for the document view. I want to use the mouse wheel strictly for a special zoom function but, if I click on the scroll bar, the mouse wheel activates both my zoom event and the natural scrolling of the window.
How do I prevent the mouse wheel from scrolling the view?
|
|
|
|
|
You just need to add a handler for WM_MOUSEWHEEL. Unless you handle it explicitly, it is translated
into WM_VSCROLLs. Just type WM_MOUSEWHEEL into MSDN help index, and there are plenty of pages which
can help you.
Good luck,
Iain.
|
|
|
|
|
Yes but I've already added a handler for WM_MOUSEWHEEL. My CScrollView now correctly zooms my view in an out with the mouse wheel but, if I click on the scroll bars, using the mouse wheel still scrolls the window as well as zooming it. It only seems to happen when a scroll bar was the last interface item clicked.
|
|
|
|
|
If you've got a
BOOL CMyView::OnMouseWheel(UINT fFlags, short zDelta, CPoint point)
{
...
}
function in your class, and a
ON_WM_MOUSEWHEEL()
in the message map, then the CScrollView::OnMouseWheel should never be called.
Unless you are calling it from your function?
I would also check the return value from the function. There are only two, so
try both. I reckon FALSE would be correct, but I can't check at the moment.
Iain.
|
|
|
|
|
Ah! That was the problem. I did prevent CScrollView::OnMouseWheel from being called but I was returning FALSE from the OnMouseWheel event. When I changed the return value to TRUE, it prevented wheel-based scrolling.
Thanks for the help!
|
|
|
|
|
Hello,
I want to create a random password generator. I would like to generate 56 chars of garbage like “₧○▲╫º╪§a2/1&*(#C23j;lc)(8sdalk+]ds<32ds?9s%ncKLJw@#*)54^”
Anyone know of any way to do this?
Rob
|
|
|
|
|
You could try using a loop and rand() to generate the ASCII codes for the characters, thats the only thing that comes to mind just now. And then swap the ASCII character into the string. Not looked in MSDN to see if thats possible and can't remember if it is.
|
|
|
|
|
char buf[ 56+1 ] ;
for ( size_t i=0 ; i < sizeof(buf)-1 ; ++i )
buf[i] = 32 + (rand() % (127-32)) ;
buf[i] = '\0' ;
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Perfect
Thanks
|
|
|
|
|
Great stuff Taka,
it was way beyond my hungover brain just now to think of the code so thanks for clearing it up for me
|
|
|
|
|
Getting the range right and avoiding off-by-one errors is such a drag, even when you're sober
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
I've been working on a small utility that needs to read/write Linux style configuration files. I have just started templating the class responsible for holding the file's content and I've run into a small problem. The following is a listing of the template declaration for the class.
template<
class Element,
class Traits = std::char_traits<Element>,
class Allocator = std::allocator<Element>,
class Container = std::map<std::basic_string<Element, Traits, Allocator>,
std::basic_string<Element, Traits, Allocator> >
>
class basic_configuration {
};
My hope was to allow for the container used for storing the key/value pairs (key=value) to be changeable via a template parameter. Unfortunately, the above code will not compile... it crashes the compiler (VC 6.0, SP5).
Any suggestions on how I might go about fixing this?
cheers,
-B
|
|
|
|
|
Here is how, for anyone who's interested.
template<
class Element,
class Traits = std::char_traits<Element>,
class Allocator = std::allocator<Element>
>
struct MyContainer {
typedef std::basic_string<Element, Traits, Allocator> string_type;
typedef std::map<string_type, string_type> type;
};
template<
class Element,
class Traits = std::char_traits<Element>,
class Allocator = std::allocator<Element>,
class Container = MyContainer::type
>
class basic_configuration {
};
cheers,
-B
|
|
|
|