473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

overlap windows, how is it possible?

dag
Hi!

I would like to do an overlap window, over my main window (of my
application), with a Progress Bar. Exactly when I push a button of my
application I want show a window, with a Progress bar, during the processing
time.

The first question is: Is it possible to have an overlap window? (I create
my windows by the "CreateWindowEx" command) By which command

Is possible to create a "MessageBox" with a progress bar?

Someone know where can I found some sample like this?

I tried to do that first with the application below, maybe someone can give
a look and suggest me something, thanks!!

#include <windows.h>
#include <commctrl.h>

HINSTANCE g_hInst = NULL; // Handle to the application instance
HWND g_hwndMain = NULL; // Handle to the application main window
HWND g_hwndMain2 = NULL; // Handle to the application main window
TCHAR g_szTitle[80] = TEXT ("Main Window"),
// Application main window name
g_szClassName[80] = TEXT ("Main window class");
// Main window class name
#define ID_COMPONTXT 1
/************************************************** *********************

FUNCTION:
WndProc

PURPOSE:
The callback function for the main window. It processes messages that
are sent to the main window.

************************************************** *********************/
LRESULT CALLBACK WndProc (HWND hwnd, UINT umsg, WPARAM wParam,
LPARAM lParam)
{
switch (umsg)
{
// Add cases such as WM_CREATE, WM_COMMAND, WM_PAINT if you don't
// want to pass these messages along for default processing.

case WM_CLOSE:
DestroyWindow (g_hwndMain);
return 0;

case WM_DESTROY:
PostQuitMessage (0);
return 0;
}

return DefWindowProc (g_hwndMain, umsg, wParam, lParam);
}

/************************************************** *********************

FUNCTION:
InitInstance

PURPOSE:
Create and display the main window.

************************************************** *********************/
BOOL InitInstance (HINSTANCE hInstance, int iCmdShow)
{

g_hInst = hInstance;
g_hwndMain2 = CreateWindow (
g_szClassName, // Registered class name
g_szTitle, // Application window name
WS_OVERLAPPED, // Window style
70, // Horizontal position of the window
120, // Vertical position of the window
100, // Window width
100, // Window height
NULL, // Handle to the parent window
NULL, // Handle to the menu the identifier
hInstance, // Handle to the application instance
NULL); // Pointer to the window-creation data
g_hwndMain = CreateWindow (
g_szClassName, // Registered class name
g_szTitle, // Application window name
WS_EX_CLIENTEDGE, // Window style
CW_USEDEFAULT,//70, // Horizontal position of the window
CW_USEDEFAULT,//120, // Vertical position of the window
CW_USEDEFAULT,//100, // Window width
CW_USEDEFAULT,//100, // Window height

NULL, // Handle to the parent window
NULL, // Handle to the menu the identifier
hInstance, // Handle to the application instance
NULL); // Pointer to the window-creation data
// If it failed to create the window, return FALSE.
if (!g_hwndMain)
return FALSE;

ShowWindow (g_hwndMain, iCmdShow);
UpdateWindow (g_hwndMain);

// If it failed to create the window, return FALSE.
if (!g_hwndMain2)
return FALSE;

ShowWindow (g_hwndMain2, iCmdShow);
UpdateWindow (g_hwndMain2);
return TRUE;

}

/************************************************** *********************

FUNCTION:
InitApplication

PURPOSE:
Declare the window class structure, assign values to the window class
structure members, and register the window class.

************************************************** *********************/
BOOL InitApplication (HINSTANCE hInstance)
{
WNDCLASS wndclass;

wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = (WNDPROC)WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hIcon = NULL;
wndclass.hInstance = hInstance;
wndclass.hCursor = NULL;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = g_szClassName;

return RegisterClass (&wndclass);
}

/************************************************** *********************

FUNCTION:
WinMain

PURPOSE:
The WinMain function of the application. It is called by the system as
the initial entry point for this Windows CE-based application.

************************************************** *********************/
int WINAPI WinMain (
HINSTANCE hInstance, // Handle to the current instance
HINSTANCE hPrevInstance, // Handle to the previous instance
LPWSTR lpCmdLine, // Pointer to the command line
int iCmdShow) // Shows the state of the window
{
MSG msg; // Message structure
HACCEL hAccel; // Handle of the accelerator
// table
// Use this code to prevent your application from starting twice
// assuming that your application has not changed its window text

if (FindWindow(g_szClassName, g_szTitle)){
SetForegroundWindow(FindWindow(g_szClassName, g_szTitle));
return FALSE;
}
if (!hPrevInstance)
{
if (!InitApplication (hInstance))
return FALSE;
}

if (!InitInstance (hInstance, iCmdShow))
return FALSE;
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

// Initialize the common controls and then create the progress bar.
int i;
int iSpacing; // Controls the size of the progress bar.
HWND hwndPB, h1, hC2; // Handle of progress bar.
INITCOMMONCONTROLSEX iccInit;
RECT rcClient, rcClient2; // Client area of the application window.

// Initialize the common controls.
iccInit.dwSize = sizeof(iccInit);
iccInit.dwICC = ICC_PROGRESS_CLASS;
InitCommonControlsEx(&iccInit);

// Create the window for the progress bar.
GetClientRect(g_hwndMain2, &rcClient2);
iSpacing = (int)(0.10 * (rcClient2.right - rcClient2.left));

GetClientRect(g_hwndMain, &rcClient);
iSpacing = (int)(0.10 * (rcClient.right - rcClient.left));
hwndPB = CreateWindowEx(0,
PROGRESS_CLASS ,
TEXT("Progess Bar"),
WS_CHILD | WS_VISIBLE ,
rcClient.left + iSpacing,
(int)((rcClient.bottom - rcClient.top)/2 - iSpacing),///2),
rcClient.right - 2 * iSpacing,
iSpacing,
g_hwndMain2,
NULL,
hInstance,
NULL);
/*h1 = CreateWindowEx(0,
PROGRESS_CLASS ,
TEXT("Progess Bar"),
WS_CHILD | WS_VISIBLE ,
rcClient.left + iSpacing,
(int)((rcClient.bottom - rcClient.top)/2 - iSpacing),///2),
rcClient.right - 2 * iSpacing,
iSpacing,
g_hwndMain,
NULL,
hInstance,
NULL);*/

hC2 = CreateWindowEx (WS_EX_CLIENTEDGE, TEXT ("edit"),
TEXT (""), WS_VISIBLE | WS_CHILD | ES_MULTILINE
|WS_VSCROLL ,//| WS_DISABLED,
0, 0, 100, 100, g_hwndMain, (HMENU)ID_COMPONTXT,
hInstance, NULL);

/*MessageBox(hwndPB,
NULL,TEXT ("Fra"), MB_OKCANCEL);*/

//Display the progress bar.
ShowWindow(g_hwndMain2, iCmdShow);
UpdateWindow(g_hwndMain2);

//Display the progress bar.
ShowWindow(g_hwndMain, iCmdShow);
UpdateWindow(g_hwndMain);

if(!h1)
{
MessageBox(g_hwndMain, TEXT("Unable to create the progress bar"),
TEXT("Progress Bar"), MB_OK);
return FALSE;
}

// Set the range and increment of the progress bar.
SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0,200));
SendMessage(hwndPB, PBM_SETSTEP, 2, 0);//MAKEWPARAM(2, 0), 0

// Send data to the progress bar to make it advance.
for(i=0 ; i < 100 ; i++)
{
SendMessage(hwndPB, PBM_STEPIT, 0, 0);
Sleep(10);
}
// Set the range and increment of the progress bar.
SendMessage(h1, PBM_SETRANGE, 0, MAKELPARAM(0,200));
SendMessage(h1, PBM_SETSTEP, 2, 0);//MAKEWPARAM(2, 0), 0

// Send data to the progress bar to make it advance.
for(i=0 ; i < 100 ; i++)
{
SendMessage(h1, PBM_STEPIT, 0, 0);
Sleep(10);
}
DestroyWindow (g_hwndMain2);
DestroyWindow (g_hwndMain);

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

// Insert code here to load the accelerator table.
// hAccel = LoadAccelerators (...);

while (GetMessage (&msg, NULL, 0, 0))
{
if (!TranslateAccelerator (
g_hwndMain, // Handle to the destination window
hAccel, // Handle to the accelerator table
&msg)) // Address of the message data
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
return msg.wParam;
}

Sep 20 '05 #1
0 1826

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dag Sunde | last post by:
Is there any way to make a <div> section overlap the (windowed) content of a java Applet? I'm asking this, because JavaScript menus usually ends up beneath Applet windows... -- Dag.
2
by: John Baker | last post by:
HI; I have a table where the user is entering data which shows scheduling for member of teams. One problem we have encountered is that sometimes the inputter (is this a word) puts in dates for...
0
by: dag | last post by:
Hi! I would like to do an overlap window, over my main window (of my application), with a Progress Bar. Exactly when I push a button of my application I want show a window, with a Progress bar,...
6
by: Robin Haswell | last post by:
Hey guys I was wondering if you could give me a hand with something. If I have two tuples that define a range, eg: (10, 20), (15, 30), I need to determine whether the ranges overlap each other....
13
by: Mike S | last post by:
I came across the following paragraph in the "Semantics" section for simple assignment in N1124 (C99 draft) and I'm wondering if I'm interpreting it right: 6.5.16.1p3: If the value being...
7
by: Cruelemort | last post by:
All, I have a div in my page that has a set width of 1000px, height of 200px, inside this i declare two more div's, both relatively positioned and floated left, the first is placed to the top...
1
Traveler33
by: Traveler33 | last post by:
When a custom control moves, how to detect when it encounter or overlap with another control? Platform: Windows XP sp2 Language: C#.net express 2005
3
by: Justin | last post by:
What is the syntax to overlap partitions? Lets assume I want a year split amount 4 months (3 partitions for a year) and later adding an additional set of partitions for every 6 months. Plus...
5
by: liketofindoutwhy | last post by:
It seems like there are only 4 methods to overlap 2 images using CSS? There are two images, each with its own URL. Using CSS, there seems to be 2 ways to overlap them (the task is actually to put...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.