|
You should be creating the control the same way you did before,
just using your new class.
All you should have to change is the class. There's no new Init function necessary.
Here's the basic shell of a CSliderCtrl derived class:
#pragma once
class CMySliderCtrl : public CSliderCtrl
{
DECLARE_DYNAMIC(CMySliderCtrl)
public:
CMySliderCtrl();
virtual ~CMySliderCtrl();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};
#include "stdafx.h"
#include "MyApp.h"
#include "MySliderCtrl.h"
IMPLEMENT_DYNAMIC(CMySliderCtrl, CSliderCtrl)
CMySliderCtrl::CMySliderCtrl()
{
}
CMySliderCtrl::~CMySliderCtrl()
{
}
BEGIN_MESSAGE_MAP(CMySliderCtrl, CSliderCtrl)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
void CMySliderCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
CSliderCtrl::OnLButtonDown(nFlags, point);
}
Create the control the same way you did before:
m_slider_bar1 = new CMySliderCtrl();
m_slider_bar1->Create(...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
I did the same thing what you have suggested in the previous post. I have included AfxMessageBox function in the constructor of CMySliderCtrl class.
but this is not executing.
then i came to know that the class constructor is not getting executing..
Below i am including the code snippet..
Here CMySliderCtrl is slider class, and CIncidentSample4Dlg class is my dialog box class. in my dilaog box class i have written create function for slider.
class CMySliderCtrl : public CSliderCtrl
{
DECLARE_DYNAMIC(CMySliderCtrl)
public:
CMySliderCtrl();
virtual ~CMySliderCtrl();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};
class CIncidentSample4Dlg : public CDialog
{
// Construction
public:
CIncidentSample4Dlg(CWnd* pParent = NULL); // standard constructor
CSliderCtrl *m_slider_bar1;
// Dialog Data
//{{AFX_DATA(CIncidentSample4Dlg)
enum { IDD = IDD_INCIDENTSAMPLE4_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIncidentSample4Dlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CIncidentSample4Dlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnCancelMode();
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_INCIDENTSAMPLE4DLG_H__1BDF3DFC_90DC_4DB5_89D3_910D63A593B4__INCLUDED_)
modified on Tuesday, February 17, 2009 10:16 AM
|
|
|
|
|
venki502 wrote: CSliderCtrl *m_slider_bar1;
That needs to be
CMySliderCtrl *m_slider_bar1;
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I have a problem with a tooltip control in a modeless dialog. I have created the tooltip like this in the dialogs OnInitDialog() function:
m_pTip = new CToolTipCtrl();
m_pTip->Create(this, TTS_ALWAYSTIP);
m_pTip->SetMaxTipWidth(250);
m_pTip->Activate(TRUE);
m_pTip->AddTool(this, "TEST");
I also call RelayEvent in PreTranslateMessage. This works fine.
But in a certain situation I must disable the parent window of the dialog, so the dialog behaves like a modal dialog.
I do this just with
m_pParentWnd->EnableWindow(FALSE);
But after this call the tooltips in my dialog do not work anymore.
Does someone have a hint for me?
Thank you
|
|
|
|
|
|
Hello Hans,
thank you for your answer. I have tried this but it does not work.
After calling AfxGetStaticModuleState() in the GetMessageProc, AfxGetApp() returns a NULL pointer within the proc. So I removed AFX_MANAGE_STATE(AfxGetStaticModuleState( )) and then the pointer is OK. (But here is no change in the tooltip behavior)
LRESULT CALLBACK GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
...
I think the problem is not that it is a modeless dialog, because when the dialog is in modeless state, the tooltips work (without any GetMessageProc). This means that PreTranslateMessage within my dialog is called.
The problem only occurs when I call
m_pParentWnd->EnableWindow(FALSE);
in the dialog class.
When I set a breakpoint in PreTranslateMessige procedure of my dialog, I can see that RelayEvent is called (But the Tooltip doens not apear):
Btw: My modeless dialog is created in the mainframe, it is not in a dll.
Any ideas?
regards
|
|
|
|
|
You got to activate the tooltip new. If it doesnt work create every tiem a new one.
Greetings from Germany
|
|
|
|
|
Hi Karsten
That's it! I just have to call Activate after disabling the parent wnd.
Thank you very much
|
|
|
|
|
I have doubt about the slider control.
I am creating slider dynamically using the below code snippet.
m_slider_bar1->Create(WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_BOTH | TBS_NOTICKS, CRect(75, 20, 500, 45), this, IDC_SLIDER1);
I am able to get the slider in the dialog box, but when i clicked on the slider at some location, iam seeing border.
I have written code like whenever you drag the mouse to some location then line should move from current location to there. the line is able to move but the new control is overriding the slider..
now what i want is, i should not get the slider with border..
Your help me will be appriciated regarding this..
Thanks
Venkatesh
|
|
|
|
|
venki502 wrote: I am creating slider dynamically using the below code snippet.
Why not at design time?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi David,
I want to create the slider at run time at specified position as that is my requirement.
But even if i create the slider at design time i am facing with the same problem.
whereever i have clicked in the slider the silider poisition is not moved directly to the respected position.
I am explaining my scenario with example below, i hope this will help you for better understanding my question.
I gave the min and max values as 0 and 100. Suppose if i clicked at 33 position, the slider position is not directlt moving to 33 location, instead it is moving to 20th location. every time the tic value is incrementing by 20.
Any help would be appriciated regarding this.
Thanks in advance.
Thanks
Venkatesh.
|
|
|
|
|
venki502 wrote: whereever i have clicked in the slider the silider poisition is not moved directly to the respected position.
See here[^].
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
This is Venkatesh, I am working on VC++ (MFC). Currently i am working on one application which deals with the graphs and lines. i want to create one line and have to move (drag) that line horizotally from one end to other using mouse.
Can any one help me out regarding this...?
Any help would be much appreciated, because as it is very urgent requirement for me..
Thanks
Venkatesh.
|
|
|
|
|
You need to declare WM_MOUSEMOVE and WM_LBUTTONUP/DOWN and you need to get current postion of mouse with GetCursorPos and then you can use of LineTo/MoveTo.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Thanks Hamid ,thanks for your valuable reply.
|
|
|
|
|
In addition to what Hamid said, you will also have to set the raster operation code to R2_XORPEN when you draw your line. Doing so you will be able to draw the line once to show the line, and then draw it again in the same spot to erase the line. Use CDC::SetROP2(R2_XORPEN) in your drawing code.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks Arends ,thanks for your valuable reply.
|
|
|
|
|
You can use Rubberbanding[^] to create the line. (Ivor Horton is the best author to reference for sample graphics applications using MFC )
To interact with it you could simply use CRectTracker with a few modifications if you don't mind a simple rectangular hit test region. This is more than adequate for forms based line manipulations since a good portion or the lines will be vertical or horizontal.
If you need more advanced hit testing that is not restricted to a rectangle, such as for an advanced graphics application, then you will likely need to roll your own tracker class.
|
|
|
|
|
Thanks bob,
Thanks for spending your valuable time for getting me to the conclusion page.
|
|
|
|
|
I am looking for something that I have not been able to find.
1. example code that analyzes the colors in a bitmap, and
2. code that organizes the colors sampled into a palette of 16x16 or 32x32 or something like that.
can anyone help?
|
|
|
|
|
Richard Perrine wrote: example code that analyzes the colors in a bitmap
Define 'analyze'. To just gather colours, I'd probably go through the bitmap a pixel at a time and store the RGB triplet for each pixel into a std::set . That would make it easy enough to get a list of the unique colours in the bitmap.
To cull the colours to a smaller number (as required if you want to define a fixed palette for the image), you'd use some form of colour quantisation[^].
Richard Perrine wrote: code that organizes the colors sampled into a palette of 16x16 or 32x32
Maybe you can get some ideas from this color picker control[^]? The source is available.
|
|
|
|
|
|
|
Hi,
I want to use an explorer in my program (it's a C++ program) which is under Windows CE platform. I want to know that is it applicable or not? If yes, does any body know how can I do it?
(If here is not a right forum, Sorry, I don't know under which topic I should write my question)
Thanks a lot
Sincerely Yours
Miss_F
|
|
|
|
|
Miss_F wrote: an explorer
What do you mean by 'an explorer'? If you mean manipulating the filesystem/namespace using explorer interfaces like IFolderView [^], then I suspect you're out of luck. If you mean a treeview, then you should be OK[^].
|
|
|
|