CommandButton.SetFocus crash process.

CommandButton.SetFocus crash process.

Post by Mike D Sutto » Thu, 10 Jul 2003 20:53:10



Quote:> I'm currently working on a project that incorporates Visual Basic V6.00
GUI that
> interacts with Visual C++ V6.00 engine in COM (VB is the client
application while
> the engine is the server).

> The GUI application receives callbacks from the engine.
> One of the callbacks is call 'LoadData', in-which a command-button control
> gets a focus:

> CmdFocus.SetFocus

> At this specific location, the application crashes with exception
'c000008f'
> which means 'Floating-point inexact result.'

> I've searched Microsoft KB for this case and encountered a problem with
CoolBar
> control, yet we do not use it at our project.

> I also tried to locate any events that might occur due to 'SetFocus' (such
as control_GotFocus
> and control_LostFocus and other hooks in the program).

> There wasn't any problems with either events.

> The project is working in Microsoft Windows 2000, SP3 environment,
developed in
> Microsoft Visual Studio V6.00, SP4.

I recently had the same problem with another heavily subclassed project, and
eventually tracked it down to something completely different (A file
couldn't be found or something completely unrelated to floating point
values.)  It turns out that the error was being scrambled by VB, and this is
a 'default' error message when something internally within VB goes wrong,
you can find more details in this KB article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;232829
The SetFocus() method is sometimes somewhat picky though about where it can
be called, make sure that the button is visible and enabled before calling
the method (Or just error trap it.)
Alternatively go the API route and set the focus manually:

'***
Private Declare Function SetFocusAPI Lib "user32" Alias _
    "SetFocus" (ByVal hWnd As Long) As Long

'...

Call SetFocusAPI(CmdFocus.hWnd)
'***

Or even:

'***
Private Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, ByRef lParam As Any) As Long

Private Const WM_SETFOCUS As Long = &H7

' ...

Call SendMessage(CmdFocus.hWnd, WM_SETFOCUS, 0, ByVal 0&)
'***

Hope this helps,

    Mike

 - Microsoft Visual Basic MVP -

WWW: Http://www.mvps.org/EDais/

 
 
 

CommandButton.SetFocus crash process.

Post by Guy » Fri, 11 Jul 2003 14:26:50


Thanks for your help on that subject; I will try it out.

Guy.



> > I'm currently working on a project that incorporates Visual Basic V6.00
> GUI that
> > interacts with Visual C++ V6.00 engine in COM (VB is the client
> application while
> > the engine is the server).

> > The GUI application receives callbacks from the engine.
> > One of the callbacks is call 'LoadData', in-which a command-button
control
> > gets a focus:

> > CmdFocus.SetFocus

> > At this specific location, the application crashes with exception
> 'c000008f'
> > which means 'Floating-point inexact result.'

> > I've searched Microsoft KB for this case and encountered a problem with
> CoolBar
> > control, yet we do not use it at our project.

> > I also tried to locate any events that might occur due to 'SetFocus'
(such
> as control_GotFocus
> > and control_LostFocus and other hooks in the program).

> > There wasn't any problems with either events.

> > The project is working in Microsoft Windows 2000, SP3 environment,
> developed in
> > Microsoft Visual Studio V6.00, SP4.

> I recently had the same problem with another heavily subclassed project,
and
> eventually tracked it down to something completely different (A file
> couldn't be found or something completely unrelated to floating point
> values.)  It turns out that the error was being scrambled by VB, and this
is
> a 'default' error message when something internally within VB goes wrong,
> you can find more details in this KB article:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;232829
> The SetFocus() method is sometimes somewhat picky though about where it
can
> be called, make sure that the button is visible and enabled before calling
> the method (Or just error trap it.)
> Alternatively go the API route and set the focus manually:

> '***
> Private Declare Function SetFocusAPI Lib "user32" Alias _
>     "SetFocus" (ByVal hWnd As Long) As Long

> '...

> Call SetFocusAPI(CmdFocus.hWnd)
> '***

> Or even:

> '***
> Private Declare Function SendMessage Lib "user32" Alias _
>     "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
>     ByVal wParam As Long, ByRef lParam As Any) As Long

> Private Const WM_SETFOCUS As Long = &H7

> ' ...

> Call SendMessage(CmdFocus.hWnd, WM_SETFOCUS, 0, ByVal 0&)
> '***

> Hope this helps,

>     Mike

>  - Microsoft Visual Basic MVP -

> WWW: Http://www.mvps.org/EDais/


 
 
 

1. Dimmed (Grayed) picture??? (Like CommandButton)

I'am making CommandButton that will replace VB.CommandButton, And to have
ability to manage MouseHover and MouseLeave. This mouse events I managed,
but here is the problem:

I tried to make dimmed picture when my control is disabled but in some cases
method that I was using isn't drawing it well.
I used hidden CommandButton, I load picture into button and than get both
pictures in memory DC.
But when control is smaller than this hidden button this method doesn't
work, and there is also problem with
pictures in some cases when I start program I lose pictures (some black area
with scalines in different colors).

1. I need some work around to make this diseabled (dimmed, grayed) picture
in memory DC so I can use it later.

Thanks for reading me q=)

2. GeForce+Linux: SLOW glCopyTexImage2D()

3. PSP X2 Crashing On File Open Or File Batch Process

4. Info For The Digital Producer

5. 64mgs...crash, crash,crash

6. snapping side to grid while rotating

7. PageMaker 6.5 + 7.6.1 = crash crash crash?

8. Cannot Buy SmartSaver Pro

9. Alien Skin 32 bit CRASH CRASH on PS3.0.4

10. CRASH CRASH!!!

11. CRASH Corel Draw 8 CRASH

12. PI 4.2 goes CRASH CRASH!

13. *****Crash Help, Crash Help*****