|
Hi,
I have a listbox which I automatically scroll down when I add new new lines (for a chat). Unfortunately, I want to avoid this autoscroll behaviour when the user decided to scroll up and look for older text. Because otherwise each new incoming text would anoyingly scroll to the end again.
Hmmm, my idea was to look on GetScrollPos() and do not autoscroll when the position is != the ending position. Is this a good idea, any other ideas?
Thx for help.
|
|
|
|
|
Deselect the autoscroll feature. When inserting a string, check first whether the cursor is at the bottom, and if so, do a SetCursel to the new line. Otherwise, do nothing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Using the scroll bar doesnt change the cursor/caret.
Also my idea with GetScrollPos() doesn't work alone. I need to calculate the TopIndex + number of visible items to get the ending position - or more easy I think: I use ItemFromPoint() and compare it with GetCount()-1. Let me implement it...
Have a nice weekend.
|
|
|
|
|
here it is:
BOOL CListBoxChat::IsAutoScroll()
{
int nBottom = GetBottomIndex();
if(nBottom == LB_ERR) return FALSE;
return (GetBottomIndex() == GetCount()-1)?TRUE:FALSE;
}
int CListBoxChat::GetBottomIndex()
{
ASSERT(m_hWnd);
CRect rect;
GetClientRect(rect);
int nIndex = LOWORD(::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(0, rect.bottom)));
if (nIndex == LOWORD(LB_ERR))
{
nIndex = LB_ERR;
}
return nIndex;
}
|
|
|
|
|
I vote that you give it a try. If it works then it is a good idea, if it doesn't work then it isn't.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
Hi there ...
I wrote a structure like this:
struct MyObject
{
CDC dc;
CBitmap bmp;
short x, y;
};
In one of my functions i want to make a refrence parameter ...
I mean the function can chenge the value which got from parameter.
It is my function:
void CTileDlg::SwapTiles(MyObject &myObj)
{
int x, y;
short col, row;
x = myObj->nX;
y = myObj->nY;
col = myObj->nCol;
row = myObj->nRow;
myObj->nX = objNULL->nX;
myObj->nY = objNULL->nY;
myObj->nCol = objNULL->nCol;
myObj->nRow = objNULL->nRow;
objNULL->nX = x;
objNULL->nY = y;
objNULL->nCol = col;
objNULL->nRow = row;
}
I have to pass MyObject pointer object to that.
For example:
MyObject *mo;
SwapTiles(mp);
Could you tell me how can i make a right refrence function ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Don't pass a pointer. Just pass the struct variable normally. It gets passed by reference.
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
MyObject *mo;
SwapTiles(*mo); Ther's a typo in your sample code --I guess you refered to the same variable mo in both sentences.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have a dialog based MFC project. I have added a menu IDR_MAINFRAME to it, also I have filled up the Accelerator resources for IDR_MAINFRAME. But when the program is running, and the accelerator key is pressed (for example, Alt+F), nothing happens. But if I click on the corresponding menu item, the function would be called. Did I miss anything?
Thank you very much in advance!
|
|
|
|
|
Nish explains it all here.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you, Joaquín and Nish. I've got the accelerator keys.
Thank you so much!
|
|
|
|
|
lucy wrote:
Thank you, Joaquín and Nish
Eight roses
4 for Joaquín and 4 for me
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
4 for Joaquín and 4 for me
It'd be nice if there was a feature at CP which allowed people to collect roses, so that later it could be consulted how many roses everybody has. Do we lobby for it?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
It'd be nice if there was a feature at CP which allowed people to collect roses, so that later it could be consulted how many roses everybody h
Good idea Joaq. Roses for everyone
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Screw roses!!!!
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
|
Maybe someone could just make sure that I am clear on IJW. Microsoft says that it simply allows a user to make pure unmannaged API calls from within ? Managed C++ ? whereas a VB or C# developer must use the DLLImport PInvoke method? Is this pretty much all this means concerning IJW/It Just Works. I must add, what a naming scheme done by Microsoft, I think they are running out of acronyms.
Nick Parker
|
|
|
|
|
You get to do your own marshalling. And it's more natural than P/Invoke. And P/Invoke is ugly.
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
|
PInvoke is the ability to call unmanaged functions exported from DLL.
IJW is similar to PInvoke works on the same mechanism except that it can be used only to call functions within the same module (DLL/EXE). Thus it is also called local PInvoke.
They both work in the same way.
|
|
|
|
|
I have a SDI application in which I replace the default VIEW by 2 splitters and 3 other views. So that I have a treeview on the left of the first splitter splitting vertically while its right hand side is again split, horizontally, to have a ListView on top and a ScrollView at the bottom.
I have a Tabctrl in the CScrollView to which I add pages, where each page is a dialog with an edit box that is populated with a report selected from the list in the listview. I need to Preview this report and print it if necessary.
How do I achieve the Preview and Printing of my reports which are a part of a dialog in the CSrollView?
Since this application is a SDI and simultaneously the contents to be previewed and print are in a dialog in my CScrollView the samples under 'Printing' section on this site hasn't helped me much.
Any ideas/suggestion are welcomed.
Thanks in advance.
-Mahesh Shimpi
Ideas grow by sharing!!
|
|
|
|
|
As your dialogs are needed for printing, create a class that inherits from CDialog and add the virtual functions
OnPrepArePrinting()
OnBeginPrinting()
OnEndPrinting()
OnPrint()
to it. These can then be overriden in the dialogs actual classes. Now your view will need to farm the calls it gets to these functions out to all the dialogs that it is displaying through the tab control. As long as each dialog knows how many pages it needs to print, everyhing should work OK.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
I am quite new to Visual C++ so this may be a very newbie question.
Is it possible to embed a CMenu in a CDialog? The reason I am asking this question is that I am not really interested in using the doc/view architecture since it doesn't really seem like a good architecture to solve my problem.
|
|
|
|
|
Create a menu resource and then go to the Dialog
template in the resource editor and see the properties
of the dialog,
There you will find Menu ; select the menu resource you want to
attach. The go back to the Menu and bring up the class wizard,
you will prompted to select a class thru which you want to route
the commands( obviously the dialog) select the dlg class.
Voila u r ready!
|
|
|
|
|
I've made a button object within core Win32, but I want to change the FONT of the button.
1. How can I change the button's font (I know how to send the message, but then...)
2. Is a HGDIOBJ compatible with HFONT, and if not, how to convert (Can it be done with type casting?)
Thanks, Sjoerd
N.B. I'm not using MFC or WTL/ATL in this.
LPCSTR Dutch = "Double Dutch "
|
|
|
|