Solved

How to make custom UI with VC++ 5?

Posted on 1998-06-30
7
310 Views
Last Modified: 2013-11-20
Hi,
   Is there a way (an easy one) to create custom User Interface for our application? For example, instead of using the standard Windows 95 application UI, I would like to create a fancy UI (kinda like WinAMP, or other Win32 MP3 players) with my own BMP file with the layout.
 
  I think I can achieve that by modifiying the .rc file, but I don't know where or how to begin.  Can anyone help me out?
0
Comment
Question by:eklee
7 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1318569
Create a frame window without a menu, title, border or whatever you want. Here is a very simple template.

#include <afxwin.h>

//-----------------------------------------------------------------------------
class CMyApp : public CWinApp
{
    public:
        virtual BOOL InitInstance();
};
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
class CMyWnd : public CFrameWnd
{
    public:
        CMyWnd();
        inline BOOL CreateWnd();
   
    protected:
        afx_msg void OnPaint();
        afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
       
        DECLARE_MESSAGE_MAP()
};
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
inline BOOL CMyWnd::CreateWnd()
{
    RECT rcWnd;
    rcWnd.top = rcWnd.left = 0;
    rcWnd.right = 100;
    rcWnd.bottom = 100;
   
    return this->Create(NULL,      // use default class name
                        _T("My Window"),
                        WS_POPUP,
                        rcWnd);
}
//-----------------------------------------------------------------------------


CMyApp theApp;


//-----------------------------------------------------------------------------
BOOL CMyApp::InitInstance()
{
    // Create an instance of our own frame window class
    CMyWnd *pWnd = new CMyWnd;
    if (!pWnd->CreateWnd())
        return FALSE;
    pWnd->ShowWindow(SW_SHOW);
   
    m_pMainWnd = pWnd;
   
    return TRUE;
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP(CMyWnd, CFrameWnd)
    ON_WM_PAINT()
    ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
//-----------------------------------------------------------------------------
afx_msg void CMyWnd::OnPaint()
{
    CPaintDC dc(this);    // device context for painting

    // draw your window here    
}
//-----------------------------------------------------------------------------
afx_msg void CMyWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
    // action here
}
//-----------------------------------------------------------------------------

0
 

Author Comment

by:eklee
ID: 1318570
Yes, but how could I associate the "Close Window", "Maximize Window", "Minimize Window" buttons to what they should do?  For example, let's say my application has a circle shape, all the "Close/Max/Min Windows" buttons are at distributed in the bottom of the circle.  Let's say I have already drawn up the layout of this circle in a bmp file.

Now, how could I make my application to use my bmp file as its 'skin'? In addition to that, how can i tell my program that the "Close/Max/Min Windows" button are located at some other places, instead of at the top right (standard) position?
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1318571
You can always catch the mouse messages yourself and respond to them as needed. For example, if the user clicks on your X bitmap and you want to interpret that as a close message, then all need is to PostMessage(WM_CLOSE). To minimize, you would use ShowWindow(SW_MINIMIZE), and ShowWindow(SW_MAXIMIZE) to maximize the window.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 

Expert Comment

by:bfwizard
ID: 1318572
Your question is a not a hard question but is a long one and deals with many issues based on your design desions...like say if you make a custom button that say Maximizes a window....In all these cases you need to overide these messages and in some cases override them completely and deal with them yourself. You have to handle all button interactions including states of your buttons..drawing them yourself and produce messages when they are pressed.  But to answer your question one would need a clear idea of what you want to do.
0
 

Author Comment

by:eklee
ID: 1318573
bfwizard,
    I guess what I want to know is how could we use a custom BMP image as the appearance of our application.  For example, if we create a custom Dialog-based application, it will still be the traditional rectangle-shaped application.  Instead of this, I would like to make the application looks like whatever BMP image we use.  
    As another example, let's say I want to write a CD-jukebox application.  It is ugly if we use standard/traditional Windows' rectangle-shaped layout.  I want to make my application looks like a jukebox (I will draw it in a BMP file) and let the user interact with it (custom buttons).  How can I do this thru VC++? I know I can do this quite easily thru Delphi 3, but I don't have it, and I prefer to work with VC++ for now.
0
 
LVL 1

Expert Comment

by:sudhirbrat
ID: 1318574
It is very easy with ActiveX controls.

In the ActiveX Control Wizard(App Wizard), check the box Window less activation and you can build your control in customized shape.
0
 
LVL 4

Accepted Solution

by:
chabaud earned 100 total points
ID: 1318575
You can intercept the WM_NCHITTEST message for your window and return HTCLOSE / HTMAXBUTTON / HTMINBUTTON or  DefWindowProc() result, depending on xPos and yPos parameters.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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