|
Dominik Reichl wrote:
It works now with EnsureVisible
Using Scroll() is just a PITA. How were you calculating the line height to do it? I probably would have used GetItemRect() and CRect::GetHeight() .
Dominik Reichl wrote:
I calculated the lastitem+1=count as last item
Yeah, that would stop it working
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
How were you calculating the line height to do it? I probably would have used GetItemRect() and CRect::GetHeight().
Nearly I've done exactly what you said, plus I added 1 to the item size because it looks like Windows adds a one-pixel line as spacer (at least on my Win98).
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Dominik Reichl wrote:
I've done exactly what you said, plus I added 1 to the item size because it looks like Windows adds a one-pixel line as spacer
Nope, Windows doesn't add a pixel to it. It's the stupid calculation that GetHeight() uses: (bottom - top) . The actual height should be (bottom - top + 1) . A rectangle where top=0 and bottom=1 is actually 2 pixels high, but GetHeight() returns 1. I don't know why CRect was written this way, but it was.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Is it possible to set the selection of text in two separate CEdit boxes at the same time? In order to highilght the first box, I use
m_approach1C.SetFocus();//set focus
m_approach1C.SetSel(0,-1);//select entire text
I must call SetFocus() for this to work, but I cannot set the focus to 2 CEdit boxes at the same time, so if I do this...
m_approach0C.SetFocus();//set focus to box 1
m_approach0C.SetSel(0,-1);//select all text in box 1
m_approach1C.SetSel(0,-1);//select all text in box 2
only the first CEdit control selects the text.
If I cannot do this, is there a way to change the background color of a CEdit box?
"Because without beer, things do not seem to go as well."
Kevin Shaffer
kshaff03@msn.com
|
|
|
|
|
Only one control (a.k.a. window) may have the focus at one time.
As for changing the background color, a search of code project should give you the answer. Try searching for things like the following: "edit control backgound color", "custum edit controls", "custum contols", and take a look at the totorials.
Trust in the code Luke. Yea right!
|
|
|
|
|
As John said, only one control can have the focus at once. Edit controls only show their selection when they have the focus, so if only one control can have focus, then only one edit control shows its text as selected. You can select text in both edit boxes, but only one will show up as selected.
kshaff03 wrote:
If I cannot do this, is there a way to change the background color of a CEdit box?
Yes. Handle WM_CTLCOLOR in your dialog. Look at the docs for more information. There are plenty of articles around as well.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hello,
I was trying out one of the articles I read here about subclassing. The article can be found at http://www.codeproject.com/miscctrl/subclassdemo.asp#xx524121xx
I have subclassed CButton and have a new class, CMyButton. Now, I added all of the functionality that I want to CMyButton and want to subclass my CButtons.
In my app I have some CButtons that are dynamically created. The user hits "Add Button" in the menu and the button appears. This is what I tried to do in order to subclass the button:
m_buttons[m_numButtons].Create(Source,WS_VISIBLE|WS_TABSTOP|BS_FLAT|<br />
BS_PUSHBUTTON|BS_ICON|BS_VCENTER, r, MainWnd,IDC_MAIN_BUTTON + m_numButtons);<br />
<br />
CWnd *pWnd = GetDlgItem(IDC_MAIN_BUTTON + m_numButtons); <br />
ASSERT(pWnd && pWnd->GetSafeHwnd());<br />
m_btnMyButton.SubclassWindow(pWnd->GetSafeHwnd());<br />
However, the bold line gives me an assertion error in WinCore.cpp:
ASSERT(FromHandlePermanent(hWndNew) == NULL);
// Must not be already in permanent map
I read at Microsoft that this implies that the control that I am attempting to subclass has already been subclassed.
Does anyone know how I can resolve this problem?
Also, in CMyButton::DrawItem I have the button turn yellow, just as the article says. However, how can I make it so the button is drawn with all of the styles I have indicated when I created the button? What I have in DrawItem is exactly as in the article but button styles are not handled in the article. For example, I want a flat, icon button that is a tab stop, but the button is drawn as a usual button and unable to be tabbed to. What do I have to add to my DrawItem function to get it to make the button flat, display the icon, and be a tab stop and have any other styles that I added when I created the original CButton, before it was subclassed?
If you have any questions please let me know.
Thanx,
-Flack
|
|
|
|
|
I believe that your issue is that when you created the buttons via the CButton class, it already has it "subclassed" to MFC wndproc. Subclassing is used to hook windows that have already been created by other means.
onwards and upwards...
|
|
|
|
|
Thanx for the reply.
Would it then be possible for me to instead of have an array of CButtons and CButtons created dynamically, and then subclass them, to instead change it to an array of CMyButtons so I wouldnt have to subclass anything?
I tried this and the the buttons would draw and turn yellow when I hover over them with the mouse but the button styles I want are not drawn.
What would I have to do in order to make the buttons draw with the style I want? Im guessing Im missing something in CMyButton::DrawItem but I dont know what.
Any help is greatly appreciated.
Thanx,
-Flack
|
|
|
|
|
Flack wrote:
Would it then be possible for me to instead of have an array of CButtons and CButtons created dynamically, and then subclass them, to instead change it to an array of CMyButtons so I wouldnt have to subclass anything?
Yes, this is the right way to do it.
Flack wrote:
What would I have to do in order to make the buttons draw with the style I want? Im guessing Im missing something in CMyButton::DrawItem but I dont know what.
All your drawing code is in CMyButton::DrawItem() . If you comment out everything in this function, then nothing will get drawn. Just make sure you are drawing the right thing .
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
This is a large question, but I wish to know if it's possible to create hardware and then access it through VC++? Perhaps make an LED light up through an USB port... I can't seem to find anything on the internet about this, does anyone know if it's even possible?
Again, I know it's a big question, but I'm just curiuos... Thanks!
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Selevercin wrote:
can't seem to find anything on the internet about this, does anyone know if it's even possible?
Of course this is possible but there is a lot of work involved. You must write a driver. Windows 9X drivers are completly different from windows NT drivers.
John
|
|
|
|
|
Hmmm... thanks for replying. Is there information on this somewhere?
Selevercin
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
I'm sorry I don't know of any good sources of info on this kind of thing. In the past we have investigated doing stuff like this but we thought that it would be too time consuming for what we got out of it..
John
|
|
|
|
|
Selevercin wrote:
Is there information on this somewhere?
Possibly here:
http://flounder.com/books.htm#Developing%20Windows%20NT%204.0%20Device%20Drivers
|
|
|
|
|
Thanks for the help... I think it's going to be too complex and time consuming to actually do it though.
Thanks again,
Nic
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Yes, device drivers are no small undertaking.
|
|
|
|
|
There is an article written in German here[^]which describes a DIY USB-interface. You can even buy the pieces and build it yourself.
If any german article does help you, the article seems to be very good.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
There is a way, and that is to used a serial interface (maybe with a USB to serial converter if you want) and control the handshake lines. This won't provide many lines, but is cheap and fast with a little bit of level shifting hardware.
Use one of the serial classes in http://www.codeproject.com/system/[^] that can directly control and read these lines.
Elaine
The tigress is here
|
|
|
|
|
I'm sorry, but "handshake lines"? I'm completely new to this sort of thing...
Thanks!
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
The serial ports (COM ports) on your PC have transmit and receive data lines, plus some input and output lines which can be used to control data flow. The standard is RS232.
[^] provides a sample pinout. These signals are driven between +10 and -10 volts and certain ones can be used as individual inputs and outputs with a little electronics. Using a serial class which allows control of individual lines will let you use 2-3 output lines withotu having to write device drivers and is a lot cheaper than buting an I/O card to put inside the PC.
In your case, two output RTS and DTR are available on a standard PCserial port connector. If two ar enough then you're ok. If you need a lot more than two then it might be best to look at adding a digital I/O card to your PC since these usually come with device drivers.
Elaine
The tigress is here
|
|
|
|
|
Thanks for the help! If I only wanted to flash an LED, then I would only need a serial port cable (and my LED) and some lines of code?
Trollslayer wrote:
[^] provides a sample pinout.
Also, was this supposed to have a link in it? Just wondering...
I would only need one output for an LED, right? I guess I would send bogus information through the output line while I wanted to have the light on?
Thanks, I know I'm asking a bunch of questions!
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Yes, one output.
If you use a line such as RTS on pin 7 of the 9 pin serial connector and ground on pin 5 then you can control the RTS pin with a serial port class that allows individual handshake pin control.
This is much better than trying to send data continuously although that would work most of the time.
Elaine
The tigress is here
|
|
|
|
|
|