|
How do I determine which CSlider is sending a message?
1. Dialog CExoSliderDlg with two sliders and two edit boxes.
2. Both sliders work, and both deliver nPos which is used to update edit box variable m_SliderValue.
3. I want IDC_SLIDER to update m_SliderValue
4. I want IDC_SLIDER2 to update m_SliderValue2.
5. I think CScrollBar* pScrollBar can tell me which slider is active.
6. I don't know how to determine which slider is active. How to do it?
IDC_SLIDER_VALUE CString m_SliderValue
IDC_SLIDER_VALUE2 CString m_SliderValue2
IDC_SLIDER CSliderCtrl m_Slider
IDC_SLIDER2 CSliderCtrl m_Slider2
void CExoSliderDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if(nSBCode == SB_THUMBPOSITION)
{
m_SliderValue.Format("%ld", nPos);
UpdateData(false);
}
else
{
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
}
|
|
|
|
|
Oliver123 wrote: 5. I think CScrollBar* pScrollBar can tell me which slider is active.
This is correct.
Oliver123 wrote: IDC_SLIDER_VALUE CString m_SliderValue
IDC_SLIDER_VALUE2 CString m_SliderValue2
Use CEdit instead of CString . Update the edit controls using SetWindowText() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
OK. But the fog still lingers a bit.
But how do I determine which slider is active? How do I use CScroll* pScrollBar to determine which of the two sliders is sending the message?
I feel like the answer is right in front of me, but I just can't grab it.
Thanks
|
|
|
|
|
I found some code that I adapted to my application. It works. It allows me to determine which of the two sliders is active, and then set the appropriate edit box to the value generated by the slider. I don't follow the reinterpret_cast<csliderctrl *="">, but it works. Here is the resulting function. (The @ are not in the code. The @ should be replaced by brackets formed with < and >, but I can't get this editor to accept them.):
void CExoSliderDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
int iActiveSlider = 0;
CSliderCtrl *Slider, *Slider2;
// Identify the sliders of the dialog box using their IDentifiers
Slider = reinterpret_cast@CSliderCtrl *@(GetDlgItem(IDC_SLIDER));
Slider2 = reinterpret_cast@CSliderCtrl *@(GetDlgItem(IDC_SLIDER2));
if( reinterpret_cast@CSliderCtrl *@(pScrollBar) == Slider )
{
iActiveSlider = 1;
}
if( reinterpret_cast@CSliderCtrl *@(pScrollBar) == Slider2 )
{
iActiveSlider = 2;
}
if(nSBCode == SB_THUMBPOSITION)
{
if (iActiveSlider ==1)
{
m_SliderValue.Format("%ld", nPos);
UpdateData(false);
}
if (iActiveSlider ==2)
{
m_SliderValue2.Format("%ld", nPos);
UpdateData(false);
}
}
else
{
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
}
-- modified at 21:00 Friday 22nd September, 2006
|
|
|
|
|
You can either type in < for < and > for >, or click the checkbox labeled "Ignore HTML tags in this message (good for code snippets)" (it's located just under the smileys).
--
A Stern Warning of Things to Come
|
|
|
|
|
Oliver123 wrote: But how do I determine which slider is active? How do I use CScroll* pScrollBar to determine which of the two sliders is sending the message?
void CExoSliderDlg::OnHScroll( UINT uSBCode, UINT uPos, CScrollBar *pScrollBar )
{
CString strValue;
strValue.Format("%u", uPos);
if ((CSliderCtrl *) pScrollBar == &m_slider1)
m_edit1.SetWindowText(strValue);
else if ((CSliderCtrl *) pScrollBar == &m_slider2)
m_edit2.SetWindowText(strValue);
else
CDialog::OnHScroll(uSBCode, uPos, pScrollBar);
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Taset wrote: I'm wishing to tweak the appearance of every form in my application. What I want is to change (for example) its border, scrollbar or caption's width/height...
Wouldn't your users get a little upset that their preferences were being ignored?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
I have created a dialog box and menu in the resource editor. How do I attach the menu to the dialog box? Any help is appreciated.
Mike
|
|
|
|
|
mla154 wrote: How do I attach the menu to the dialog box?
Using the same resource editor that you used to create the dialog and the menu.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Go to Dialog properties->General tab. in Menu option select the id of the menu.
KIRAN PINJARLA
|
|
|
|
|
It worked! Thanks for your help.
Mike
|
|
|
|
|
mla154 wrote: I have created a dialog box and menu in the resource editor. How do I attach the menu to the dialog box? Any help is appreciated.
Select the menu id in the dialog box editor
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|
|
hi,
I want to handle vertical scrolling messages sent from a CListView control, so I mapped WM_VSCROLL message.. it works fine but I dont receive a message when I scroll the control by draging the scroll box and I do not know why!!!
any ideas?
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
List controls use the LVM_SCROLL message not WM_HSCROLL and WM_VSCROLL .
|
|
|
|
|
Hi,
thank you, but how can I receive this message, and how is it received in the parent window of the control?? I cant see it in the class wizard..
i tried to use the WM_NOTIFY message of the parent but it doesnt work... and no luck with MSDN..
Can u provide further help??
Thanks
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
look at "dc.SelectObject(&pen)" and "dc.SelectObject (&brush)",here no matter I use "&" or not it results the same. why is that?
[code]
void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
CBrush brush (RGB (255, 0, 0));
CPen pen (PS_NULL, 0, (RGB (0, 0, 0)));
dc.SelectObject(&pen);
dc.SelectObject (&brush);
dc.Ellipse (0, 0, 200, 100);
}
|
|
|
|
|
bloodwinner wrote: look at "dc.SelectObject(&pen)" and "dc.SelectObject (&brush)",here no matter I use "&" or not it results the same. why is that?
Because CGdiObject , which is what CPen and CBrush are derived from, has a HGDIOBJ() operator. Control eventually goes to CDC::SelectObject(HGDIOBJ hObject) . When a pointer is passed instead, control goes right to CDC::SelectObject(CPen* pPen) .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
do you mean both these two ways are ok? which would you prefer here?
|
|
|
|
|
bloodwinner wrote: do you mean both these two ways are ok?
Sure. Otherwise, why would both exist?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi All,
I have an application developed using VC++. This application uses mail merge for word 2003. This application opens a word document and a xls file for data source. Does anyone have a sample code that does a mail merge??..
Thanks,
Bharani
|
|
|
|
|
The mail merge code that I have uses HTML file as data source. The mail merge object opens the data source using the function call shown below:
mailmergeobj.OpenDataSource(
strFilename,
(LPVARIANT)COleVariant( CString("html")),
&vtFalse,
covOptional,
covOptional,
covOptional,
covOptional,
covOptional,
covOptional,
covOptional,
covOptional,
covOptional,
covOptional,
covOptional,
covOptional,
covOptional);
mailmergeobj.Execute(covOptional);
When this code is executed it comes up with a popup for "Select Table". Can someone tell me how to suppress this popup??
Thanks
Bharni
|
|
|
|
|
bharanidharan wrote: Does anyone have a sample code that does a mail merge??..
Not sure but the obvious place to look would be Office Developer Center[^] at Microsoft.
led mike
|
|
|
|
|
I have a jpg. Image that shows up in a picture control in my application. I can draw a small rectangle over the image using the Rectangle function. However using this function, the inside of the rectangle gets painted the color of the Brush. There is no current color for transparent, so how do i get the region inside the rectangle to not have a color but just show whatever is on the image at that point?
Is this possible using the Rectangle function?
|
|
|
|
|
Either select a NULL_BRUSH into the DC before drawing the rectangle, or better, use a PEN to manualy draw the outline for the rectangle yourself.
|
|
|
|
|
NULL_BRUSH seems to make the inside black. Is this what it is supposed to do?
|
|
|
|