Showing tag results for Code

Aug 4, 2004
Post comments count0
Post likes count0

Never leave focus on a disabled control

Raymond Chen

One of the big no-no's in dialog box management is disabling the control that has focus without first moving focus somewhere else. When you do this, the keyboard becomes dead to the dialog box, since disabled windows do not receive input. For users who don't have a mouse (say, because they have physical limitations that confine them to the keyboar...

Code
Aug 4, 2004
Post comments count0
Post likes count2

Why .shared sections are a security hole

Raymond Chen

Many people will recommend using shared data sections as a way to share data between multiple instances of an application. This sounds like a great idea, but in fact it's a security hole. Proper shared memory objects created by the CreateFileMapping function can be secured. They have security descriptors that let you specify which users are all...

Code
Aug 2, 2004
Post comments count0
Post likes count0

How to set focus in a dialog box

Raymond Chen

Setting focus in a dialog box is more than just calling SetFocus. A dialog box maintains the concept of a "default button" (which is always a pushbutton). The default button is typically drawn with a distinctive look (a heavy outline or a different color) and indicates what action the dialog box will take when you hit Enter. Note that this is no...

Code
Jul 29, 2004
Post comments count0
Post likes count0

When should you use a sunken client area?

Raymond Chen

The WS_EX_CLIENTEDGE extended window style allows you to create a window whose client area is "sunken". When should you use this style? The Guidelines for User Interface Developers and Designers says in the section on the Design of Visual Elements that the sunken border should be used "to define the work area within a window". Spec...

Code
Jul 27, 2004
Post comments count0
Post likes count1

Disabling the program crash dialog

Raymond Chen

If you don't want your program to display the standard crash dialog, you can disable it by setting the SEM_NOGPFAULTERRORBOX flag in the process error mode. The simple-minded way is just to do but this overwrites the previous error mode rather than augmenting it. In other words, you inadvertently turned off the other error modes! Unfortunat...

Code
Jul 23, 2004
Post comments count0
Post likes count0

Why do some process stay in Task Manager after they've been killed?

Raymond Chen

When a process ends (either of natural causes or due to something harsher like TerminateProcess), the user-mode part of the process is thrown away. But the kernel-mode part can't go away until all drivers are finished with the thread, too. For example, if a thread was in the middle of an I/O operation, the kernel signals to the driver res...

Code
Jul 23, 2004
Post comments count0
Post likes count0

Why do some process stay in Task Manager after they’ve been killed?

Raymond Chen

When a process ends (either of natural causes or due to something harsher like TerminateProcess), the user-mode part of the process is thrown away. But the kernel-mode part can't go away until all drivers are finished with the thread, too. For example, if a thread was in the middle of an I/O operation, the kernel signals to the driver res...

Code
Jul 20, 2004
Post comments count0
Post likes count1

Querying information from an Explorer window

Raymond Chen

Sometimes software development is inventing new stuff. But often, it's just putting together the stuff you already have. Today's puzzle is one of the latter type of problem. Given a window handle, you can you determine (1) whether it is an Explorer window, and if so (2) what folder it is viewing, and (3) what item is currently foc...

Code
Jul 19, 2004
Post comments count0
Post likes count0

Wrapper templates to make writing callback functions slightly easier

Raymond Chen

I previously discussed why callback functions must be static if they are member functions. Writing the correct prototype for the callback function is usually somewhat clumsy. It's not hard. Just clumsy. (If you read my previous article, you'd recognizing sticking a __stdcall in the declaration for RealThreadProc as a micro-optimization.) Every c...

Code