|
Try this. Call GetClientRect, alter the coordinates, then call MoveWindow to update.
Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that ...
Author: George Carlin
|
|
|
|
|
What are you trying to accomplish here? If you change the size of your window, the size of the client changes also. By default, the client is the size of the window, less borders, scrollbars, etc. - if you wish to make it smaller, that is possible, but it is not possible for the client area to ever be larger than the size of the window. Seeing as you're working with a CScrollView , you probably want SetScrollSizes() or some such.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades.
I don't know what you thought; I'm not your astronaut...
|
|
|
|
|
Hello
I need a ListBox that will provide functionality of both single selection and multiple selection listboxes. That means I should be able to singly or multiply make selections in a listbox. I develop with Visual c++ 6.0. What would you suggest ? How would one make it ? I need not to play with colors or anything else. Any help would be greatly appreciated.
Nice Ozgurce
|
|
|
|
|
Nice Özgürce wrote:
That means I should be able to singly or multiply make selections in a listbox.
Why the fuss? A multiselect listbox can do both. Otherwise, you'll need to create both controls on the dialog's template and hide/show each accordingly.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
You are right. I am just a newbie.
I have another simple question which I am sure you could easily give a solution.
suppose ; I have a dialog and on this dialog there is a editbox(say m_edit1) and a button. When I enter some text in this editbox(m_edit1) and push the button, I want this action(buttons onclick event) to create a popup window on which there is an editbox(say m_edit2) to be filled with the information(text, string whatever) sent from the parent dialog(the info provided thru m_edit1).
What should I do ?
Should I declare m_edit1 public, private or what ?
Should I include first class's header file in the popup window ?
What should I write to pass the m_edit1's text into popup's m_edit2.text ?
Thank you for your help
Nice Özgürce
|
|
|
|
|
class dialog2 : CDialog
{
public:
CString str;
private:
CEdit edit;
};
BOOL dialog2::OnInitDialog()
{
edit.SetWindowText(str);
} In the button handler:
dialog2 dlg;
dlg.str = text_from_the_edit_control;
dlg.DoModal();
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I do that in a dialog I use when sometimes I need to limit the user to one selection. In OnInitDialog, I just add this code based on a parameter which is set by the calling code.
if (m_bSingleSelection)
m_lbxSymbols.ModifyStyle(0, LVS_SINGLESEL);
else
m_lbxSymbols.ModifyStyle(LVS_SINGLESEL, 0);
This will turn multiselect on and off. Set the original style in the resource editor to multiselect.
Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that ...
Author: George Carlin
|
|
|
|
|
How can i learn using PerformanceGraph ...it is very important... if you know any document or article!!
|
|
|
|
|
This may be a simple question, but I'm having difficulty finding the answer or finding an example. I have a ListViewCtrl in my app, in which I want to expand the last column to be the maximum width without adding a horizontal scroll bar at the bottom. I can set the width properly, when there is no scrollbar, but how can I detect the presence of a scrollbar and adjust my width accordingly? I can use GetSystemMetrics to determine the width of the scrollbar and make the adjustment, if there is a scroll bar. How can I tell?
BTW, this is a non-MFC app. WTL/ATL are being used.
Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that ...
Author: George Carlin
|
|
|
|
|
Well not to rub it in, but if you had done it in MFC you could do something as easy as this:
<br />
m_lClientConn.InsertColumn(0, "Thread ID", LVCFMT_CENTER);<br />
m_lClientConn.InsertColumn(1, " IP address ", LVCFMT_CENTER);<br />
m_lClientConn.InsertColumn(2, " Port ", LVCFMT_CENTER);<br />
m_lClientConn.InsertColumn(3, " Agency Alias ", LVCFMT_CENTER);<br />
m_lClientConn.InsertColumn(4, " Status ", LVCFMT_CENTER);<br />
m_lClientConn.InsertColumn(5, "Comments", LVCFMT_CENTER);<br />
m_lClientConn.SetExtendedStyle(LVS_EX_FULLROWSELECT);<br />
for(int i = 0; i < 6; i++)<br />
{<br />
m_lClientConn.SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER);<br />
}<br />
<br />
<br />
My list control comes out right every time without a scroll bar across the bottom.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom,
I can use LVSCW_AUTOSIZE_USEHEADER with WTL/ATL also, but this only autosizes the column when I doubleclick on the header. Otherwise, the autosize parameter does not do anything. I need it to size the column appropriately on initialization, and after data has been added to the listbox and there may or may not be a vertical scrollbar present.
Maybe I can simulate doubleclicking on the header? Or am I doing something wrong? I'm trying to avoid a horizontal scrollbar across the bottom, by setting the column width just right.
BTW, we are converting our app to ATL/WTL from MFC because of the overhead of MFC. Although this particular piece of functionality is new.
Thanks for the response.
Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that ...
Author: George Carlin
|
|
|
|
|
It's much easier for you to just send a LVM_SETCOLUMNWIDTH message to the control, passing the column number as the first parameter, and LVSCW_AUTOSIZE_USEHEADER as the second (see MSDN). But, in answer to your question, it doesn't matter - scrollbars are generally part of the non-client area of a window, so you can just call GetClientRect() to get the width sans scrollbars (and borders, etc...).
If neither of these works for you, i have some code around somewhere for doing this sort of thing - let me know.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades.
I don't know what you thought; I'm not your astronaut...
|
|
|
|
|
Apparently, you can't just set the column width to LVSCW_AUTOSIZE_USEHEADER and expect it to resize as the list control is redrawn. I had to include this line...
ListView_SetColumnWidth(m_lbxSymbols, iCol, LVSCW_AUTOSIZE_USEHEADER);
in the OnInitDialog, OnSize (because the dialog/control is resizable), and after I load data into the list.
I had been under the impression, that this was like a style setting, but I guess it is actually a size value - one that is computed for you and you must set the size whenever the list control changes in size or content.
Thanks for your help.
Susan
Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that ...
Author: George Carlin
|
|
|
|
|
Yes, one thing that my dialog app is not doing is resizing. So this is why i set this like I did. Also I have this in my OnInitDialog so the headers are sized correctly upon creation of the dialog box.
I'm assuming that when you mean resize you mean the whole screen.....but now I am thinking that you mean as data is entered you want the fields to resize to their lengths...right?
I understand why you are switching to WTL/ATL....someday I need to move over to that and get out of MFC....but old habits are hard to break.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I was wondering if anyone knew the function to let a program perform a left mouse click. im happily moving the mouse cursor with SetCursorPos() but cant seem to find anything that allows my program to perform a click once SetCursorPos() has put the cursor in the right spot over the button. anyone else know? thanks.
|
|
|
|
|
Send a WM_COMMAND message to the parent window simulating the button click message of the child button control.
|
|
|
|
|
Take a look at mouse_event or SendInput()
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Just send a WM_LBUTTONDOWN message with appropriate params to the button, followed by a WM_LBUTTONUP message (again with appropriate params - see MSDN). You don't even have to bother with the SetCursorPos() , as these messages must be sent with the mouse position as a parameter (unless you want the user to see his mouse cursor jumping all over).
Alternately, if you know the ID of the button, you can send a WM_COMMAND message with a BN_CLICKED parameter (and the other parameter w/ handle and ID of the button) to the parent window of the button.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades.
I don't know what you thought; I'm not your astronaut...
|
|
|
|
|
our software is on a CD to customers, do you know how to protect the software from been copied (illegally) - i.e. disk copy etc?
any suggestions or aticles?
thx
includeh10
|
|
|
|
|
check the serial numer of the CD. if it doesn't match then they copied it. The only problem is can you make multipule CD's with the same serial number.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom,
do you know which c++ functions are used for checking serial number of a CD?
thx
includeh10
|
|
|
|
|
Hi:
is is possible to add extern hyperlinks into the help file afxcore.rtf?
|
|
|
|
|
Hi All,
I am new to MFC and so I thought I would set myself a small project as an exercise which is:- To read in an ASCII file from the hard disk (like the Notepad program). Then to add a button called "process" on the top row next to help. When pressed this button should process the displayed data in some way, then display the altered data on the screen. I should be able to then save that data to file.
The first part is accomplished with the helpful tutorial here
http://www.geocities.com/mcoiii2000/MFCtutorial.html to produce a simple text editor. and I have added the button to the top line
but now to manipulate....here is the task I set myself
Read in QWERTY contained in a file "ascii.txt"
All done with the created text editor. The button "process" is pushed (ok to here).
Now I want to display YTREWQ and save the file. i.e I now have a file ascii.txt containing ytrewq.
Simple? -not to me
The question, how can data from that filename be stored into an array/variable in order to be manipulated and then re displayed and saved??
Thanks for your help!
If I get it working I'll put it in the examples section!
|
|
|
|
|
Hi,
If your file contains only text, you can use CStdioFile for file processing. Open the File with file path and read the content, store CString varibale.
Finally, reverse that sting and save it.
Regards,
Selvam
|
|
|
|
|
Thanks , I really don't understand I am so new to this.
If I have made myself clear, I have constructed a simple text editor and loaded a file called ascii.txt I have added a button which when pushed takes me to the code below. Obviously I have to add the code. I actually want to manipulate the data on the screen. Where is it stored? what is the variable called?
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::Onreverse()
{
// TODO: Add your command handler code here
// I have used file>load >ascii.txt. The file contents are being displayed on the screen. Now I want to manipulate the data
// load the data displayed on the screen (qwerty)how with MFC , where is it?
// reverse it (ytrewq)-code for me to write!
// update the screen - how with MFC?
}
I can then save it to file. done with file>save
I hope that makes some sense
Thank you all for your time and help
|
|
|
|