|
Please explain what you mean by "it does not work" and provide relevant code snippet.
|
|
|
|
|
Hi Cédric Moonen,
Basically my class is subclass of CStatic.
I set scrollinfo using below code
void CImageViewer::PreSubclassWindow()
{
CRect rect;
GetClientRect( &rect );
SCROLLINFO si;
ZeroMemory( &si, sizeof( SCROLLINFO ));
si.cbSize = sizeof( SCROLLINFO );
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = nScrWidth;
si.nPage = rect.Width();
si.nPos = 0;
si.nTrackPos = 0;
SetScrollInfo( SB_HORZ, &si );
CStatic::PreSubclassWindow();
}
and handled OnHScroll Message
void CImageViewer::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
SCROLLINFO si;
int nScrollPos = nPos;
pScrollBar->GetScrollInfo( &si );
int nCurPos = si.nPos;
int nMin = si.nMin;
int nMax = si.nMax;
switch( nSBCode )
{
case SB_THUMBPOSITION:
case SB_THUMBTRACK:
nScrollPos = si.nTrackPos;
break;
case SB_LEFT:
nScrollPos = nMin;
break;
case SB_RIGHT:
nScrollPos = nMax;
break;
case SB_LINELEFT:
nScrollPos = nCurPos - 2;
break;
case SB_LINERIGHT:
nScrollPos = nCurPos + 2;
break;
case SB_PAGELEFT:
nScrollPos = nCurPos - 5;
break;
case SB_PAGERIGHT:
nScrollPos = nCurPos + 5;
break;
case SB_ENDSCROLL:
nScrollPos = nCurPos;
break;
}
if(nScrollPos < nMin) nScrollPos = nMin;
else if(nScrollPos > nMax) nScrollPos = nMax;
pScrollBar->SetScrollPos( nScrollPos );
Invalidate();
CStatic::OnHScroll(nSBCode, nPos, pScrollBar);
}
After this a scroll bar appears with my control. But i can't change scroll position.
-kk.tvm-
|
|
|
|
|
kk.tvm wrote: But i can't change scroll position.
Do you mean that the scroll is displayed properly and that you can use it correctly but it doesn't have any effect on your drawing ?
That's what I would guess by seeing your code, since you do not do anything with the scroll position (it's a local variable). What you need to do is remember the scroll position and use it when you draw your picture: you have to apply it as an offset to the picture. It's not because you added a scroll bar to a control that it will magically move when you use the scrollbar. You have to do that yourself by shifting the picture when the scroll is moved.
|
|
|
|
|
Hi Cédric Moonen
ok, i want to write code to scroll the image.
what i mean....
Scrollbar is properly shown with control. But when i press arrow heads (left or right) or thumb it does not move or changed, like disabled.
thanks in advance
-kk.tvm-
|
|
|
|
|
Perhaps your increments are too small compared to the full lenght of the scroll bar. Did you check with the debugger to see the values nMin, nMax, ... to see if everything seems correct ? And compare them to the -2/+2 you add when you click the arrow. I guess they are neglectable compared to nMax.
|
|
|
|
|
Hi Cédric Moonen
Thanks a lot of your valuable reply
-kk.tvm-
|
|
|
|
|
|
Most SIM card readers connect to the computer by USB, that would be a good place to start
|
|
|
|
|
Hi, I have two menu resources (IDR_MAINFRAME) with different conditions (created using 'right mouse-> Insert Copy' on original). I use them in different Releases. The thing is I can't get second one to load, always the original one is shown. I set condition for both VER1 and VER2, I manage Project Properties in resource and c/c++->Preprocessor parts but still cant get the the second one to be loaded?
Thanks in advance
|
|
|
|
|
Try running through the debugger to see exactly what resource id you are using when you try to show the menu.
It's time for a new signature.
|
|
|
|
|
you better load and set the menu at runtime, so you get better control of it.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
It's an IDR_MAINFRAME menu, it loads I guess in MainFrm::OnCreate, why doe I need to do all that, why doesn't it loads corectly?
|
|
|
|
|
your second menu has and different identifier or language. IDR_MAINFRAME2 ? So it wont get loaded, but the standard one.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
No the ID is the same "IDR_MAINFRAME", but they have difrerent 'Language' and 'Condition' property set.
Thanks
|
|
|
|
|
I have a Visual C++ application. In my application I show a list of all the
printers installed. I get the
list of priters with EnumPrinters() function and level 2. However I am
interested only in fetching a list of physical printers and not the Virtual
Priters like "Microsoft Office Document Image Writer" and "Adobe PDF".
How does one distinguish a physical printer from a virtual printer?
I have already looked up DeviceCapabilities() API and DEVMODE structure and
EnumPrinters() with different values for the parameter "Level". But nothing
seems to return valid information to identify if a pinter is virtual or
physical printer. Can someone provide some pointers? Links to some sample
code? thanks in advance.
|
|
|
|
|
You should enumerate the different buses like the USB bus to get all connected devices.
Even then it is not guaranteed that a detected printer is not virtual because some packages like the Device Simulation Framework (DSF) from Microsoft installs a bus driver at the lowest layer in the stack which helps create virtual devices like printers.
|
|
|
|
|
lek258 wrote: In my application I show a list of all the printers installed. I get the list of priters with EnumPrinters() function and level 2. However I am interested only in fetching a list of physical printers and not the Virtual Priters like "Microsoft Office Document Image Writer" and "Adobe PDF".
How does one distinguish a physical printer from a virtual printer?
Did you, or someone that looks like you, ask this same question over four years ago?
Also see here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
What do you have against virtual printers? I think a pdf printer is one of the best IT tools...
And it saves tons of paper.
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Hi sir,
I have some data in combo box,
First if i select any data from ComboDropDown.
The value is coming as "empty"
Second time if i select and data ,its displaying the value
Any idea,For your information,here is the code
void CTest1View::OnSelchangeCombo1()
{
CString SelectedOption;
m_ctrlCombo.GetWindowText(SelectedOption);
AfxMessageBox(SelectedOption);
}
For Example :
ComboBox Contains values "A","B","C".
If First i select any value from ComboBox i.e either A,B or C
Its showing empty,second time its working fine.
Am i doing anything wrong
|
|
|
|
|
See here [^] (i.e. Please don't cross-post).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
OK, I've been away for a while and it looks like you're faster than you were ever.
I am nothing special; of this I am sure. I am a common man with common thoughts, and I’ve led a common life. There are no monuments dedicated to me and my name will soon be forgotten, but I’ve loved another with all my heart and soul, and to me, this has always been enough. - The Notebook
|
|
|
|
|
Rajesh R Subramanian wrote: OK, I've been away for a while
St. Peter & Paul is a holyday in Mumbai as it is in Rome?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Try this instead:
CString str;
m_Combo.GetLBText(m_Combo.GetCurSel(), str);
AfxMessageBox(str);
I am nothing special; of this I am sure. I am a common man with common thoughts, and I’ve led a common life. There are no monuments dedicated to me and my name will soon be forgotten, but I’ve loved another with all my heart and soul, and to me, this has always been enough. - The Notebook
|
|
|
|
|
Just a sidenote: GetCurSel might return CB_ERR (-1 i believe), you might want to handle that case differently (i think GetLBText used to raise an ASSERT if you fed it with a negative value, that might have changed since i saw it though)
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Hi sir,
Thanks a lot,its working fine.
Raj
|
|
|
|