Solved

How to prevent flicker, in tool/status bars ?

Posted on 2000-03-10
3
346 Views
Last Modified: 2013-12-03
I added few lines to VC++ 6.0
default Hello Wold program under win 32
option to add tool and status bars.
I created them, and size them
#include <commctrl.h>
#include <afxres.h>
#pragma comment(lib, "comctl32")

#define MAX_LOADSTRING 100

// Global Variables:
HWND hWndStatus, hWndTool;
TBBUTTON tbButtons[] =
{
      {STD_FILENEW, ID_FILE_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0},
      {STD_FILEOPEN, ID_FILE_OPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0, 0}
};

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
      InitCommonControls();
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }
      hWndStatus = CreateStatusWindow(WS_CHILD | WS_BORDER  |WS_VISIBLE, TEXT(""),
         hWnd, ID_STATUSBAR);
   SetWindowText(hWndStatus, TEXT("STATUS"));
   hWndTool = CreateToolbarEx(hWnd, WS_CHILD | WS_BORDER  | WS_VISIBLE,
         ID_TOOLBAR, 2, (HINSTANCE) HINST_COMMCTRL, IDB_STD_SMALL_COLOR, (LPCTBBUTTON) &tbButtons,
         2, 0, 0, 16, 16, sizeof(TBBUTTON));
   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

AND SIZING IS AS:


            case WM_SIZE:
                  SendMessage(hWndTool, WM_SIZE, 0, 0);
                  SendMessage(hWndStatus, WM_SIZE, 0, 0);
                  break;

but I can not prevent alot of flickering,
what is the better way ?
0
Comment
Question by:hasmet
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 200 total points
ID: 2604940
okay to improve what you have there add WS_CLIPCHILDREN to the options when you create your main window

  hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

and use

PostMessage(hWndTool, WM_SIZE, 0, 0);
PostMessage(hWndStatus, WM_SIZE, 0, 0);

it also looks like your hello world is being drawn where you toolbar is so you will have to adjust for that so you can see it

HTH

Shaun Wilde
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2604947
I feel greedy taking 200 points like that so if you want to reject and resubmit with 50 points - I will not hate you or anything
0
 
LVL 1

Author Comment

by:hasmet
ID: 2606179
200, is fine and I will give it to you,
but still there is more flicker in the tool bitmaps, and status text, than
other applications such as visual studio,
any more ideas  please ????
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now