Solved

How to prevent flicker, in tool/status bars ?

Posted on 2000-03-10
3
369 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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