|
Hopefully the question is pretty descriptive.
Paradise is where I am.
Voltaire
|
|
|
|
|
|
Hi All,
my program has one dialog box. On the dialog box I have put
some buttons, 2 edit box components, some comboboxes and some labels,
I was wondering what can I do to move the components around on the sheet
when I want to resize the dialog box. I want to keep the components
at the same distance of the nearest dialog border, and I want to resize the CEdit boxes.
Any idea how to do that in run time?
Thanks!
John
|
|
|
|
|
Writing, writing and writing.
Use SetWindowPlacement.
You need to relocate the buttons each time that you recize the Dialog.
Make this in the OnSize Message
Good Luck!!!!
Carlos Antollini.
|
|
|
|
|
That function is only for window resizing.
How can I resize the components on the window?
It must be possible something like this
void CTestDlg::OnSize(UINT nType, int cx, int cy)
{
CButton *pCloseButton;
pCloseButton = (CButton*) GetDlgItem(IDCLOSE);
pCloseButton->Move(10,10);
}
Is there something like a move methode???
Thanks,
John
|
|
|
|
|
Like the original post said, you need to call it for child windows as well. A link has been provided to a class here that allows you to set rules by which child windows are automatically sized. I've not tried it myself, but it's the only other option to a list of MoveWindow or SetWindowPos calls in your OnSize code.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
From codeproject->Dialogs:
http://www.codeproject.com/dialog/resizabledialog.asp
http://www.codeproject.com/dialog/dynwindow.asp
|
|
|
|
|
check july issue at msdn magazine:
http://msdn.microsoft.com/msdnmag/issues/01/07/default.asp
http://msdn.microsoft.com/msdnmag/issues/01/07/winmgr/winmgr.asp
|
|
|
|
|
Thanks all for your help!
|
|
|
|
|
Please help me out.
I have a COleDataObject class in which i have the data in the Clipboard. If the data format in clipboard is bitmap, i need to store it in a file.
What i did is
i got the HGLOBAL from the COleDataObject and using GlobalLock i got void* pointer. Then I used CFile and created a file of extension .bmp and I used CArchive's Write function to write the raw data into the file.
But after this if i try to open the file using MS paint, it says unrecognized format.
Someone tell me what am i actually supposed to do. Thanks
Ganesh.M.Ramaswamy
|
|
|
|
|
forget it. i just made it.
Ganesh Ramaswamy
|
|
|
|
|
I'm converting a listbox control to be a list control and in reviewing the code I came across a method of CListbox that doesn't have a similar method in CListCtrl. The method is GetSelItems(int, LPINT). Did I completely miss something?
After thinking about what would be needed, I came up with the following code as a replacement. Comments or suggestions are welcome. Thanks.
int CMyListCtrl::GetSelItems(int nMax, LPINT paIndex)
{
int i;
POSITION pos = GetFirstSelectedItemPosition();
for ( i = 0; (i < nMax && pos); i++ )
{
*paIndex[i] = GetNextSelectedItem(pos);
}
return i;
}
Chris
|
|
|
|
|
Did I completely miss something?
I don't think so. List control implemented in comctl32.dll doesn't have the equivalent of LB_GETSELITEMS which is wrapped by CListBox::GetSelItems. Is this a real problem - performance-critical stuff, etc.?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
With it missing, I'll have to implement it myself
I'm replacing a listbox with a list control and just trying to minimize the code changes in the dialog class. I'll probably end up using the code I posted previously. Thanks for the help. At least I wasn't overlooking something obvious.
Chris
|
|
|
|
|
I'm converting a listbox control to be a list control and in reviewing the code I came across a method of CListbox that doesn't have a similar method in CListCtrl. The method is GetSelItems(int, LPINT). Did I completely miss something?
After thinking about what would be needed, I came up with the following code as a replacement. Comments or suggestions are welcome. Thanks.
int CMyListCtrl::GetSelItems(int nMax, LPINT paIndex)
{
int i;
POSITION pos = GetFirstSelectedItemPosition();
for ( i = 0; (i < nMax && pos); i++ )
{
*paIndex[i] = GetNextSelectedItem(pos);
}
return i;
}
Chris
|
|
|
|
|
I am having problems with setting focus to a editbox from a handler of a CListCtrl's item changed. The handler does everything it is suppose to but sets the focus to the edit box. I have an idea of what is happening but i dont know how to work around it. I think the problem is that maybe the editbox get focus but later after my handler return control back to MFC handler focus is return back to the List. All the controls are created by code not the dialog editor.
Is there anything I can do? I don't want to use a Timer w/ CWnd either?
Thank you...
|
|
|
|
|
add different font color text lines to a CRichEdit?
|
|
|
|
|
You need to use CRichEditCtrl::SetSelectionCharFormat()
A sample:
First Select the text with SetSel and then
CHARFORMAT cf;
cf.dwMask = CFM_COLOR;
cf.dwEffects = CFE_AUTOCOLOR;
cf.crTextColor = (COLORREF)RGB(100, 100, 100);
pRichEditCtrl->SetSelectionCharFormat(cf);
Cheers!!!
Carlos Antollini.
|
|
|
|
|
I know that this question has been asked here a few times before but the answers haven't quite been to my problem.
My limited understanding of how printing works is that the client area of the MDI/SDI is transfered to the printer using device contexts. My application is dialog based and the data I want to print resides in a database and I don't have a client area. Therefore I will I believe, need to build the printed page in memory using the data first before transfering it to the printer.
I have read Chris Maunder's Printing article but still don't see how I am going to get this to work.
Has anyone else done this?
If so can someone please give me a push in the right direction. Code snippets or full working examples greatfully accepted.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
KB article Q133275 "HOWTO: Print from a Class Other Than CView" may be helpful.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I would like to know how i could use the method find when i don't want to specify the name of my column but its index. I would like to use find for different table which have the same form (number of columns and rows) but where the fields name are different. For example i want to find record in the first column, whatever the table.
thanks in advance
gerald
|
|
|
|
|
it's Impossible. You need to inform the name of the field.
Carlos Antollini.
|
|
|
|
|
What can cause a CRecordset object to be readonly? My CDatabase object is tested to be open and updatable so that's not the problem.
I can use the recordset to fetch records from the database table and I've verified that my recordset contains a record. I also make sure to position the cursor at the first record. But still CanUpdate() returns false.
I've tried opening the recordset as both dynaset or snapshot, but neither works. I don't use the CRecordset::readOnly paramter either.
I'm also quite sure there's no permission restraints in my table, since updates using ExecuteSQL works fine.
Does anyone recognize this problem and could tell me what to try? Or maybe give me a pointer to a good faq about MFC and databases?
My database table contains fields of the following types: int, datetime, smallint and numeric. It has an auto-generated primary key of type int.
Any advice will be much appreciated.
Thanks,
Jimmy Ehrnström
|
|
|
|
|
The class CRecordset don't work fine.
A lot of people have the same problem.
You can make two things.
If you want to be a good database programer, never Update a Table usign the metodo AddNew or Update, is better to use SQL Sentences. Like INSERT or UPDATE using ExecuteSQL. If you are using a SQL Server or Oracle or like some this, Please use Stored Procedures, for update, insert, and delete records, Is better, Quickly and more secure for the programer and for the DBA, because you don't need permits over the table you only need permit of execute in the stored, Also is easy for Admin, because if you add a field into a table, sometimes you only need to modify the store and not the VC++ Code.
Best Regards.
Carlos Antollini.
|
|
|
|
|
With all the problems I've had with my recordsets I can only believe that your right. It's strange though that I haven't found any warnings about recordsets, just small examples where they mostly use recordsets to fetch data. You could think that MFC classes should work fine together with SQL server, but obviously that's not very true.
I'll guess I have to switch to stored procedures, like you suggested. Hopefully the redesigning will be minimal and maybe I'll save time in the long run.
Thanks a lot for your 2 cents.
|
|
|
|