Click here to Skip to main content
15,911,785 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Subclassing problem: WM_LBUTTONDOWN is missing Pin
Axonn Echysttas25-Jan-06 0:16
Axonn Echysttas25-Jan-06 0:16 
GeneralRe: Subclassing problem: WM_LBUTTONDOWN is missing Pin
Ryan Binns25-Jan-06 0:18
Ryan Binns25-Jan-06 0:18 
GeneralRe: Subclassing problem: WM_LBUTTONDOWN is missing Pin
Axonn Echysttas25-Jan-06 0:22
Axonn Echysttas25-Jan-06 0:22 
QuestionManifest == dud ? Pin
Swinefeaster24-Jan-06 11:47
Swinefeaster24-Jan-06 11:47 
AnswerRe: Manifest == dud ? Pin
Christian Graus24-Jan-06 14:14
protectorChristian Graus24-Jan-06 14:14 
GeneralRe: Manifest == dud ? Pin
S Douglas24-Jan-06 20:37
professionalS Douglas24-Jan-06 20:37 
GeneralRe: Manifest == dud ? Pin
Swinefeaster25-Jan-06 15:26
Swinefeaster25-Jan-06 15:26 
QuestionErase Window Pin
sidkraft24-Jan-06 11:39
sidkraft24-Jan-06 11:39 
// MainFrame.cpp
#include "MainFrame.h"

#include <stdlib.h> // for __min() "2 underscores"

#define ID_SB 210 // All child windows require an
// identifier. Not used here.

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
// message calls this function
ON_WM_PAINT() // void OnPaint()
ON_WM_LBUTTONDOWN() // void OnLButtonDown(...)
ON_WM_RBUTTONDOWN() //Left Button Down Add************
ON_WM_SIZE() // void OnSize(...)
ON_WM_CHAR() // void OnChar(...)
END_MESSAGE_MAP()

CMainFrame::CMainFrame() // Constructor
{
// Step 1: Register a window class if wish

// Step 2: Create the window
Create(NULL, "Ex06a_StatusBar & Shapes",
WS_OVERLAPPEDWINDOW,
CRect(0,0,360,250));

// Step 3: Create a status bar
myStatusBar.Create (WS_CHILD | WS_VISIBLE,
CRect(1,2, 1,2), this, ID_SB);

int rtEdges[] = {45,140,250}; // Right edge of panes
myStatusBar.SetParts (3,rtEdges);

// Step 4: Create Pens, Brushes, Fonts, etc
penReg.CreatePen (PS_SOLID, 10, RGB(0,0,255));

// Step 5: Initialize application variables
nPts = 0;
ShapeKind = 'L';
CenterWindow();
};

void CMainFrame::OnPaint()
{
CPaintDC dc (this);
dc.TextOut (1,1,"Click left button repeatedly. Press L, B, P");
CString s;
s.Format("# pts:%d", nPts);
myStatusBar.SetText (s,0,0);

s.Format ("Shape(L,B,P): %c", ShapeKind);
myStatusBar.SetText(s,2,SBT_POPOUT);

if (nPts <= 1)
return;

dc.SelectObject (&penReg);

switch (ShapeKind)
{
case 'L':
dc.Polyline (ShapePts, nPts);
break;
case 'P':
dc.SelectStockObject(LTGRAY_BRUSH);
dc.Polygon (ShapePts,nPts);
break;
case 'B':
if ((nPts - 4) % 3 == 0)
dc.PolyBezier(ShapePts,nPts);
else
{ // use max legal # of pts
int n = (nPts - 4)/3;
int NPts = __min(n*3 + 4, nPts);
dc.PolyBezier(ShapePts,NPts);
// then draw polyline
dc.SelectStockObject (BLACK_PEN);
dc.Polyline (ShapePts,nPts);
}
break;
default:
break;
}
}

void CMainFrame::OnLButtonDown (UINT nFlags,
CPoint pt)
{
if (nPts >= 99) // array full
return;
else
{
ShapePts[nPts] = pt;
nPts++;

CString s;
s.Format("Last ptFrown | :( d, %d)",pt.x, pt.y);
myStatusBar.SetText (s,1,SBT_NOBORDERS);

Invalidate();
}
}

void CMainFrame::OnChar (UINT nChar,
UINT nRep, UINT nFlags)
{
TCHAR ch = (TCHAR)nChar;
ch = toupper(ch);

if (ch == 'D')
{
if (nPts> 0) nPts--;
}
else
{
ShapeKind = ch;
if (ShapeKind == 'L' ||
ShapeKind == 'P' ||
ShapeKind == 'B')
; // okay, go on
else
ShapeKind = 'L';
}
Invalidate();
}

void CMainFrame::OnSize (UINT nType,
int cx, int cy)
{
// Done so statusbar moves to window bottom.
// Needed in older versions of Win95.
myStatusBar.MoveWindow(0,1,2,3); // coords ignored
}

void CMainFrame::OnRButtonDown (UINT nFlags,
CPoint pt)
{
Invalidate();
UpdateWindow();
}
Note: Code above was to erase the window whenever the right button on the mouse is "clicked" doesn't work, any ideas? Sid Kraft

Sid
AnswerRe: Erase Window Pin
Christian Graus24-Jan-06 14:16
protectorChristian Graus24-Jan-06 14:16 
QuestionHow to get the handle of a Popup Menu for a window? Pin
Xiangyang Liu 刘向阳24-Jan-06 9:38
Xiangyang Liu 刘向阳24-Jan-06 9:38 
AnswerRe: How to get the handle of a Popup Menu for a window? Pin
Laxman924-Jan-06 17:33
Laxman924-Jan-06 17:33 
AnswerRe: How to get the handle of a Popup Menu for a window? Pin
Ryan Binns24-Jan-06 17:58
Ryan Binns24-Jan-06 17:58 
GeneralRe: How to get the handle of a Popup Menu for a window? Pin
Xiangyang Liu 刘向阳25-Jan-06 13:56
Xiangyang Liu 刘向阳25-Jan-06 13:56 
AnswerRe: How to get the handle of a Popup Menu for a window? Pin
Hans Ruck24-Jan-06 22:30
Hans Ruck24-Jan-06 22:30 
QuestionMRU in a popup submenu Pin
manosza24-Jan-06 9:17
manosza24-Jan-06 9:17 
QuestionPassword protect a document Pin
arnoldkempt24-Jan-06 8:41
arnoldkempt24-Jan-06 8:41 
AnswerRe: Password protect a document Pin
Maximilien24-Jan-06 8:47
Maximilien24-Jan-06 8:47 
GeneralRe: Password protect a document Pin
arnoldkempt25-Jan-06 7:27
arnoldkempt25-Jan-06 7:27 
AnswerRe: Password protect a document Pin
sps-itsec4624-Jan-06 12:56
sps-itsec4624-Jan-06 12:56 
QuestionMS Access ODBC Compact and Repair Pin
Anfernius24-Jan-06 6:20
Anfernius24-Jan-06 6:20 
QuestionWTF: std::string.find_first_of woes Pin
Sebastian Schneider24-Jan-06 5:25
Sebastian Schneider24-Jan-06 5:25 
AnswerRe: WTF: std::string.find_first_of woes Pin
Christian Graus24-Jan-06 14:20
protectorChristian Graus24-Jan-06 14:20 
GeneralRe: WTF: std::string.find_first_of woes Pin
Sebastian Schneider25-Jan-06 2:07
Sebastian Schneider25-Jan-06 2:07 
Question__gc* equivalent in VC++ 2005 Pin
madhusri24-Jan-06 4:32
madhusri24-Jan-06 4:32 
AnswerRe: __gc* equivalent in VC++ 2005 Pin
toxcct24-Jan-06 4:34
toxcct24-Jan-06 4:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.