|
I have a CString that is holding a date. I want this date to be the max date in the microsoft datepicker.
the function is -
void SetMaxDate(DATE newtime);
My question is how do you fill DATE?
I can not find any documentation for DATE.
|
|
|
|
|
You can use a COleDateTime (which is the MFC wrapper for the DATE type). You can set the date and time in the COleDateTime object using ParseDateTime(). ParseDateTime will take in strings in any of the standard Windows Date Time formats. Then you can just pass your object into the SetMaxDate function, which will cast the object to a DATE. For example:
COleDateTime vtMaxDate;
CString vcstrMaxDate = _T("01-01-2001");
vtMaxDate.ParseDateTime(vcstrMaxDate);
SetMaxDate(vtMaxDate);
Hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
|
Hello,
I'm trying to write an OLE DB Wrapper class and have created a function called SetStringFieldValue and inside that function I need to set 1 columns data to the string passed to the function. I have yet to find any examples of SetData anywhere and for some reason its not working for me. Any help is greatly appreciated.
void COleDBWrapper::SetStringFieldValue(int nIndex, LPCTSTR lpszValue)
{
CString strValue(lpszValue);
IRowsetChange* pIRowsetChange = (IRowsetChange*)m_pUnkRowsetChange;
IRowsetUpdate* pIRowsetUpdate = (IRowsetUpdate*)m_pUnkRowsetUpdate;
IAccessor* pIAccessor = NULL;
HACCESSOR hAccessor;
ULONG cBindings = 1;
DBBINDING rgBinding[1];
memset(rgBinding, 0, sizeof(DBBINDING));
char szValue[50];
_tcscpy(szValue, strValue.GetBuffer(0));
rgBinding[0].iOrdinal = nIndex;
rgBinding[0].dwPart = DBPART_VALUE|DBPART_STATUS|DBPART_LENGTH;
rgBinding[0].obLength = (strValue.GetLength() + 1) * sizeof(TCHAR);
rgBinding[0].obStatus = (strValue.GetLength() + 1) * sizeof(TCHAR);
(CString)rgBinding[0].obValue = szValue; // -- DOESN'T DO JACK! -- //
rgBinding[0].wType = DBTYPE_STR;
rgBinding[0].pTypeInfo = NULL;
rgBinding[0].pObject = NULL;
rgBinding[0].pBindExt = NULL;
rgBinding[0].dwMemOwner = DBMEMOWNER_CLIENTOWNED;
rgBinding[0].cbMaxLen = (strValue.GetLength() + 1) * sizeof(TCHAR);
rgBinding[0].dwFlags = 0;
HRESULT hr = m_pUnkRowset->QueryInterface(IID_IAccessor, (void**)&pIAccessor);
if (FAILED(hr))
return;
hr = pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, 1, rgBinding, 0,
&hAccessor, NULL);
if (FAILED(hr))
return;
hr = pIRowsetChange->SetData(m_hRow, hAccessor, szValue);
// hr is ALWAYS DB_E_ERRORSOCCURRED
}
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I'm trying to write an OLE DB Wrapper class
It sounds like reinventing the wheel - can't you use ATL OLEDB consumer templates?
hr is ALWAYS DB_E_ERRORSOCCURRED
IErrorRecords should give you more detailed information. See DBViewer sample for details. You may also check the status variables associated with fields.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
IErrorRecords::GetDescription and GetSource both give me "M" so they were no help. Also, I am writing my own wrapper class because the templates are ok but they are still too primative. Thank you for your response.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
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
|
|
|
|