Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows

Posted on 1999-06-29
8
Medium Priority
?
235 Views
Last Modified: 2010-04-02
Hi,

a.I would like to have an example of how creating a windows and displaying it on win95.

b.I aslo would like to have a status bar, the c++ program that I am creating will take some time so I would like to display where about the program is to inform the user that it's still running and doing some stuff. Can anyone give me an example of that too...

Thanks for your help.
0
Comment
Question by:yesnaud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 5

Expert Comment

by:Tom Knowlton
ID: 1198698
Which compiler are you using?

For example, Borland C++ Builder, Microsoft Visual C++?

If you have C++ Builder, I'd be happy to send you some source code / demos on what you're trying to do.
0
 
LVL 1

Author Comment

by:yesnaud
ID: 1198699
Sorry it was for VC++ 6.0

0
 
LVL 5

Expert Comment

by:Tom Knowlton
ID: 1198700
It's been a long time since I've programmed in VC++.  There are plenty of people who DO know it, though.  I'm sure they'll be along shortly.  :)

Good luck.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:Shay050799
ID: 1198701
go to file->new
and choose project
than choose MFC exe application, and walk through the instruction
0
 
LVL 1

Author Comment

by:yesnaud
ID: 1198702
I don't want to go through the instruction, I want to have a simple code, to create a window, and a status bar...

Sorry.
0
 
LVL 1

Expert Comment

by:BSoeters
ID: 1198703
Use all these files below, together with the library "comctl32.lib" (common controls).

The functions "CreateStatusWindow()", "DrawStatusText()" and "MenuHelp()" could be of some help to you. You might find it worthy to look into them.

You can look in the online help for "Platform, SDK, and DDK Documentation" -> "Platform SDK" -> "User Interface Services" -> "Common Controls" -> "Status Windows".

Hope this helps !

-----[ statusbar.c ]------------------------------------------------------------

/***************************************************************************
Standard Windows headers
***************************************************************************/

#define STRICT
#include <windows.h>

#include <commctrl.h> /* for common controls support, maybe diff in NT */

#include <stdio.h> /* for sprintf */

/***************************************************************************
Special headers
***************************************************************************/

#include "resource/resource.h"   /* for the identifiers into .rc */

/***************************************************************************
Definitions
***************************************************************************/

#define NROF_STATUSPARTS 6  /* number of partitions in the status window */

/***************************************************************************
Prototyping
***************************************************************************/

BOOL CALLBACK MainWindow (HWND, UINT, WPARAM, LPARAM);

/***************************************************************************
Globals
***************************************************************************/

HINSTANCE g_hInstance   = NULL; /* global: current application instance handle */
HWND      g_hMainWindow = NULL; /* global: main window handle */
HWND      g_hStatusBar  = NULL; /* global: status bar window handle */

/***************************************************************************
Application entry point
***************************************************************************/

int WINAPI WinMain (HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR     szCmdLine,
                    int       iCmdShow)
{
MSG msg;

g_hInstance = hInstance;

/* Initialize common controls library */
InitCommonControls();

/* Create a modeless dialog box, using a dialog from the resource script file
   In this particular case, the dialog "IDD_MAIN" in the .rc file is used.    */

g_hMainWindow = CreateDialog (hInstance, MAKEINTRESOURCE (IDD_MAIN), NULL, &MainWindow);

if (g_hMainWindow)
   {
   while (GetMessage (&msg, NULL, 0, 0))
         {
         if (g_hMainWindow == NULL || !IsDialogMessage (g_hMainWindow, &msg))
            {
            TranslateMessage (&msg);
            DispatchMessage (&msg);
            }
         }

   if (g_hMainWindow)
      {
      DestroyWindow (g_hMainWindow);
      g_hMainWindow = NULL;
      }
   }

return (0);
}

/***************************************************************************
Main window message handler
***************************************************************************/

BOOL CALLBACK MainWindow (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
BOOL  handledmsg = FALSE; /* Message handled or not state  */

RECT rcclient;
int  statuspartwidth;
int  statuspart[NROF_STATUSPARTS];
int  index;
int  style;
char sbtext[256];

switch (msg)
       {
       case WM_INITDIALOG: /* Create the status window */
                           g_hStatusBar = CreateWindow (STATUSCLASSNAME, "",
                                                        WS_CHILD | WS_VISIBLE,
                                                        0, 0, 0, 0,
                                                        hwnd, NULL, g_hInstance, NULL);

                           if (g_hStatusBar)
                              {
                              GetClientRect (hwnd, &rcclient);
                              statuspartwidth = rcclient.right / NROF_STATUSPARTS;

                              for (index = 0; index < NROF_STATUSPARTS; index++)
                                  statuspart[index] = statuspartwidth * (index + 1);

                              SendMessage (g_hStatusBar, SB_SETPARTS, NROF_STATUSPARTS, (LPARAM) statuspart);

                              for (index = 0; index < NROF_STATUSPARTS; index++)
                                  {
                                  switch (index % 3)
                                         {
                                         case 1 : style = SBT_POPOUT;
                                                  break;

                                         case 2 : style = SBT_NOBORDERS;
                                                  break;

                                         default: style = 0;
                                                  break;
                                         }

                                  sprintf (sbtext, "Statusbar part %d", index);
                                  SendMessage (g_hStatusBar, SB_SETTEXT, index | style, (LPARAM) sbtext);
                                  }
                              }

                           handledmsg = TRUE;
                           break;

       case WM_CLOSE:      SendMessage (hwnd, WM_DESTROY, 0, 0);
                           handledmsg = TRUE;
                           break;

       case WM_DESTROY:    if (g_hStatusBar)
                              {
                              DestroyWindow (g_hStatusBar);
                              g_hStatusBar = NULL;
                              }

                           PostQuitMessage (0);

                           handledmsg = TRUE;
                           break;
       }

if (msg == WM_COMMAND)
   {
   switch (LOWORD (wp))
          {
          case IDCANCEL:
          case IDOK:     SendMessage (hwnd, WM_CLOSE, (WPARAM) 0, (LPARAM) 0);
                         handledmsg = TRUE;
                         break;
          }
   }

return (handledmsg);
}





-----[ resource.h ]-------------------------------------------------------------

//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Statusbar.rc
//
#define IDD_MAIN                        101

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1001
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif





-----[ statusbar.rc ]-----------------------------------------------------------

//Microsoft Developer Studio generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_MAIN DIALOG DISCARDABLE  0, 0, 352, 111
STYLE DS_3DLOOK | DS_NOFAILCREATE | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP |
    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Statusbar"
FONT 8, "MS Sans Serif"
BEGIN
    PUSHBUTTON      "E&xit",IDOK,295,7,50,14
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
    IDD_MAIN, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 345
        TOPMARGIN, 7
        BOTTOMMARGIN, 104
    END
END
#endif    // APSTUDIO_INVOKED


#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED


0
 
LVL 1

Author Comment

by:yesnaud
ID: 1198704
Hi, it doesn't seem to find this function:

IsDialogMessage

Y.
0
 
LVL 1

Accepted Solution

by:
BSoeters earned 200 total points
ID: 1198705
Make sure you are linking to user32.lib.

That library contains the IsDialogMessage() function. The function is prototyped in the winuser.h headerfile.

Kind regards,
Bob
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

661 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