Toolbar flat style (TBSTYLE_FLAT) and painting problem (MFC) ?

Toolbar flat style (TBSTYLE_FLAT) and painting problem (MFC) ?

Post by Jarkko Muhone » Thu, 11 Sep 1997 04:00:00



Hi

I'm trying to use a standard toolbar with TBSTYLE_FLAT like below

        if (!m_wndRecordBar.Create(this) ||
                !m_wndRecordBar.LoadToolBar(IDR_MAINFRAME))
        {
                TRACE0("Failed to create Bar\n");
                return -1;
        }
        m_wndRecordBar.ModifyStyle(0, TBSTYLE_FLAT);

Everything is find until I try to move toolbar. Repainting doesn't work.
Has anyone had the same problem ?

Thanks
        Jarkko

-----------------------------------------------------------------------  
Jarkko Muhonen, Project Manager
Relatech Oy (http://www.relatech.fi)
Ylist?nm?entie 24
FIN-40500 Jyv?skyl?
Tel: +358 14 561624, Fax: +358 14 650 120,

-----------------------------------------------------------------------

 
 
 

Toolbar flat style (TBSTYLE_FLAT) and painting problem (MFC) ?

Post by Steffen Man » Thu, 11 Sep 1997 04:00:00


 Jarkko Muhonen schrieb im Beitrag

>Hi

>I'm trying to use a standard toolbar with TBSTYLE_FLAT like below

> if (!m_wndRecordBar.Create(this) ||
> !m_wndRecordBar.LoadToolBar(IDR_MAINFRAME))
> {
> TRACE0("Failed to create Bar\n");
> return -1;
> }
> m_wndRecordBar.ModifyStyle(0, TBSTYLE_FLAT);

>Everything is find until I try to move toolbar. Repainting doesn't work.
>Has anyone had the same problem ?

>Thanks
>        Jarkko

>-----------------------------------------------------------------------
>Jarkko Muhonen, Project Manager
>Relatech Oy (http://www.relatech.fi)
>Ylist?nm?entie 24
>FIN-40500 Jyv?skyl?
>Tel: +358 14 561624, Fax: +358 14 650 120,

>-----------------------------------------------------------------------

I had the same problem, but could fix it with help from www.msj.com
(Microsoft System Journal).
Thay have the CFlatBar class with the fix. In this class they just
invalidate the old toolbar region, then move it.
But there is another problem: when I move the toolbar and resize it (toolbar
has button groups) I get hal buttons (the window is to small) - could not
fix this.
Dowes anyone have an idea?

bye
--
Steffen Mann
TU Dresden, Fakultaet Informatik
www:
   http://www.inf.tu-dresden.de/~sm4
   http://atlantis.wh2.tu-dresden.de/~manne
eMail:


Tel.: 0171-4144868

 
 
 

Toolbar flat style (TBSTYLE_FLAT) and painting problem (MFC) ?

Post by Stefan Kuh » Wed, 17 Sep 1997 04:00:00



> I had the same problem, but could fix it with help from www.msj.com
> (Microsoft System Journal).
> But there is another problem: when I move the toolbar and resize it (toolbar
> has button groups) I get hal buttons (the window is to small) - could not
> fix this.
> Dowes anyone have an idea?

> bye
> --
> Steffen Mann

I encountered the same problem and have a solution for the half-drawn
buttons:

In addition to Paul DiLascia's code from MSJ add a handler for
WM_WINDOWPOSCHANGED to the flatbar, call the base class version
from within this handler and after that call

    RedrawWindow(NULL,NULL, RDW_INVALIDATE|RDW_FRAME);

This will fix the problem with the half-drawn buttons.

Another problem are toolbar buttons with radiobutton-functionality,
because buttons that change from the 'on-state' to the 'off state'
because of some other button is clicked and changes to the 'on state'
are not properly redrawn. This can be easily fixed by adding a handler
for WM_LBUTTONUP: From this handler first call the base class version
and after that add this call:

    PostMessage(WM_IDLEUPDATECMDUI, (WPARAM)TRUE, 0L);

There is still some strange behaviour in the flat toolbar, even if
you apply these fixes, for instance if a floating toolbar is
docked at one edge where another toolbar is docked, the frame around
the newly docked toolbar is not properly drawn if you do not place
the toolbar *exactly* onto the location where it will afterwards
appear in the docked state.
But maybe someone else will fix this problem.

--
Best Regards,

Stefan Kuhr, software development staff Homag AG Schopfloch, Germany
 (Please remove REMOVE_THIS from my email address to send me mail.)

 
 
 

Toolbar flat style (TBSTYLE_FLAT) and painting problem (MFC) ?

Post by Stefan Kuh » Wed, 17 Sep 1997 04:00:00



>     PostMessage(WM_IDLEUPDATECMDUI, (WPARAM)TRUE, 0L);

Sorry, I forgot to mention that you need to include the private
mfc-header file afxpriv.h in your flat tool bar's source file for
WM_IDLEUPDATECMDUI to be defined.

--
Best Regards,

Stefan Kuhr, software development staff Homag AG Schopfloch, Germany
 (Please remove REMOVE_THIS from my email address to send me mail.)

 
 
 

Toolbar flat style (TBSTYLE_FLAT) and painting problem (MFC) ?

Post by al.. » Wed, 24 Sep 1997 04:00:00


Hi

        I'm creating a process that monitors a directory for when a file arrives there.

        I'm using FindFirstChangeNotification to determine if
something has changed in the directory
        and then
        I'm using FindFirstFile to look for the specified file

        The problem is, of course, that I'm notified immediately or once enough cache has been written to disk,
about the existance of this file.

        I need to know when the file is "done arriving" so that I can process a full file and not one that is
in the stages of being created.

        I know, I can tell it to look for a trigger file, but this adds extra coding to any creating process
which may not be extensible to these things.

        Is there a way, through API's, that I can check if another process "owns" the file?

        Is there any other way?

Thanks in advance for even reading this far.

Alex Ignacz

 
 
 

Toolbar flat style (TBSTYLE_FLAT) and painting problem (MFC) ?

Post by Scott McPhillip » Wed, 24 Sep 1997 04:00:00



> Hi

>         I'm creating a process that monitors a directory for when a file arrives there.

>         I'm using FindFirstChangeNotification to determine if
> something has changed in the directory
>         and then
>         I'm using FindFirstFile to look for the specified file

>         The problem is, of course, that I'm notified immediately or once enough cache has been written to disk,
> about the existance of this file.

>         I need to know when the file is "done arriving" so that I can process a full file and not one that is
> in the stages of being created.

>         I know, I can tell it to look for a trigger file, but this adds extra coding to any creating process
> which may not be extensible to these things.

>         Is there a way, through API's, that I can check if another process "owns" the file?

>         Is there any other way?

> Thanks in advance for even reading this far.

> Alex Ignacz

Use the FILE_NOTIFY_CHANGE_LAST_WRITE option in
FindFirstChangeNotification.  It's a lot closer to what you want, but
not perfect.  I find I still have to try opening a new file in exclusive
mode and loop around a little bit if it won't open yet to make sure it
is all done.
 
 
 

Toolbar flat style (TBSTYLE_FLAT) and painting problem (MFC) ?

Post by Jerry Coff » Sun, 28 Sep 1997 04:00:00




Quote:> Hi

>    I'm creating a process that monitors a directory for when a file arrives there.

>    I'm using FindFirstChangeNotification to determine if
> something has changed in the directory and then I'm using
> FindFirstFile to look for the specified file

Since your subject line mentions NT, you might want to use
ReadDirectoryChangesW instead of FindFirstChangeNotification - it will
tell you the name of the modified file directly.

Quote:>    The problem is, of course, that I'm notified immediately or once enough cache has been
> written to disk, about the existance of this file.

>    I need to know when the file is "done arriving" so that I can process a full file and
> not one that is in the stages of being created.

One obvious method would be to spin off a thread that attempts to open
the file for exclusive access, and if it fails sleeps for 100
milliseconds (or so) and tries again.

--
    Later,
    Jerry.

The Universe is a figment of its own imagination.