|
If you check the documentation you see that CClientDC's constructor[^] gets a CWnd (or derivate) pointer, my guess would be that your own class has nothing to do with CWnd. Explain a bit more what you want to do.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
modified on Monday, February 23, 2009 8:59 AM
|
|
|
|
|
What I meant was :
In MFC single document, I want to show Text on main window. And I also want this function to be operated in my 'own' class(which is a derived class of CWnd), not in CView class.
Pallini's answer is the best solution to my question (how nice of him/her ). It works well.
And now I've found another solution.
void CMyclass::memfunc()
{
AfxGetApp()->m_pMainWnd->GetDC()->TextOut(x, y, "..");
}
Thank you for your kind answer.
May the sky bring you a full measure of health and prosperity.
|
|
|
|
|
I see. Sorry if i misunderstood anything, good luck with your project.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
MFC, STUDIO 2008, ADO , ACCESS’2003
Database IDENTITY_mdb.mdb already is opened.
Below strings of the code are attached to command button that is on dialog window.
_ConnectionPtr m_pConn2;
_bstr_t m_s = "GRANT SELECT ON IDENTITY_mdb.mdb TO Karl,ED,Alex,Michel";
How to set two last parameters into Execute()?
Variant_1:
m_pConn2->Execute(m_s, 0, 0); // Can not open system database Microsoft Jet.
Variant_2:
m_pConn2->Execute(m_s, "Provider=Microsoft.Jet.OLEDB.4.0;"
"Data Source = D:\\CD_MY_new\\ReadDB_using_CDatabase\\IDENTITY_mdb.mdb",
adModeUnknown); // error C2664: 'Connection15::Execute' : cannot convert parameter 2 from 'const char [100]' to 'VARIANT *'
|
|
|
|
|
MFC, STUDIO 2008, ADO , ACCESS’2003
How copy from controls CEdit that is on MODELESS dialog window
class CMyModeless2 : public Cdialog
into columns of CListBox of
class CAdodc_my : public Cdialog ?
CMyModeless2* m_pModeless;
_RecordsetPtr pRsmodeless;
CString m_s;
m_s=m_pModeless->m_strPP_modeless; // OK!
SetDlgItemText(IDC_EDIT1, m_s); // OK!
"PP" - the name of column into table
void CAdodc_my::OnRButtonDown(UINT nFlags, CPoint point)
{
// Below attempts is uncorrectly when is execution:
pRsmodeless->Fields->GetItem ("PP")->Value = (_bstr_t) m_pModeless->m_strPP_modeless;
(_bstr_t) pRsmodeless->Fields->GetItem ("PP")->Value = "aaaaaa";
(char *) (_bstr_t) pRsmodeless->Fields->GetItem ("PP")->Value = "aaaaaa";
pRsmodeless->Fields->GetItem("PP") = (_bstr_t) (LPCTSTR) m_pModeless->m_strPP_modeless;
(_bstr_t)pRsmodeless->Fields->GetItem ("PP")->Value = (_bstr_t) m_pModeless->m_strPP_modeless;
// Below error of compilation:
(_bstr_t) (LPCTSTR) pRsmodeless->Fields->GetItem("PP") = m_pModeless->m_strPP_modeless;
(_bstr_t) (LPCTSTR) pRsmodeless->Fields->GetItem("PP") = (_bstr_t) m_pModeless->m_strPP_modeless;
(LPCTSTR) pRsmodeless->Fields->GetItem("PP") = (_bstr_t) m_pModeless->m_strPP_modeless;
LPCTSTR) pRsmodeless->Fields->GetItem("PP") = (m_pModeless->m_strPP_modeless;
(_bstr_t) pRsmodeless->Fields->GetItem("PP") = m_pModeless->m_strPP_modeless;
_variant_t) pRsmodeless->Fields->GetItem("PP") = (_variant_t) m_pModeless->m_strPP_modeless;
modified on Tuesday, February 24, 2009 2:35 AM
|
|
|
|
|
CHIVOTIOV wrote: How copy from controls CEdit that is on MODELESS dialog window
What exactly does this mean?
CHIVOTIOV wrote: // Below error of compilation:
Are we supposed to guess what the compiler error is?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
DavidCrow wrote: Are we supposed to guess what the compiler error is?
Yes, after all, since you are the inventor of, your CPMRU should have its battery pack fully charged...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello
I make R&D virtual printer driver and I am using HP Color LaserJet 8500 PCL driver for
EMF spool file generation. It is not grayscale supported printer driver .SO when I print color
Document to black/ white use with color selection. But the EMF spool files in color.
If I convert EMF to BMP, the BMP size is as per as printer size 5000*4000 …so large. So it takes more time for image processing.
SO
Any one suggests how to convert direct color EMF file to black/ white or gray scale EMF file.
or
Suggest any grayscale, Color and Black/White also default EMF spool file generator Printer name.
Or
Any otherWay?
Thanks
Mahendra
|
|
|
|
|
Hi there.
Incase a stored precedure returns a set of records, then I can read the same by below code...
while(!recordset-> EndOfFile)
{
_variant_t var;
var = recordset->Fields->GetItem(L"TestName")->GetValue();
var = recordset->Fields->GetItem(L"TestID")->GetValue();
recordset->MoveNext();
}
Now, incase a stored precedure retunrs only a single value, lets say a hardcoded value "100", then how can I get that.
My main problem is, I am not aware of the column type, so how to read this returned value? please suggest.
Thanks
PanB
|
|
|
|
|
Well, you may check the variant type, usign its vt member. But would it be of any usage (if we esclude mere reporting)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am not able to get any relevent info.
Lets say my stored precedure is...
Create Procedure usp_ReturnSingleValue
AS
DECLARE @ReturnValue INT
SET @ReturnValue = 100
Select @ReturnValue
go
Now I want to read the returned value i.e., 100 from my c++ code.
|
|
|
|
|
Got it.
One need not pass any column name...
var = recordset->Fields->GetItem(L"")->GetValue();
Thanks Buddy for your help.
|
|
|
|
|
Hello,
I have to customize a old project to work with Cyrillic Characters. I have the following code:
CString MyText;
TCHAR buf[512];
SendMessage(lCurHwnd,WM_GETTEXT,sizeof(buf)/sizeof(TCHAR),(LPARAM)(void*)buf);
MyText.Format("%s",buf);
If the buf contains Cyrillic Characters (like Привет) this will be replaced with ??????.
Do you know a way to solve this problem? This is my first meeting with Cyrillic Characters in a project and I do not know how to correct it.
I am using Windows XP, SP2, Visual Studio in English.
Thank you!
|
|
|
|
|
You should build for unicode i guess.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi all,
I have used wizard mode propertysheet,font of all property pages not change form dialog box property so i m using this to change font of property pages.
font is changed now,but the property page not fit to property sheet,i mean the property page not fully visible.
my code is.
extern CFont fArial,fArial1;
enum { CDF_CENTER, CDF_TOPLEFT, CDF_NONE };
void ChangeDialogFont(CWnd* pWnd, CFont* pFont, int nFlag)
{
CRect windowRect;
TEXTMETRIC tmOld, tmNew;
CDC * pDC = pWnd->GetDC();
CFont * pSavedFont = pDC->SelectObject(pWnd->GetFont());
pDC->GetTextMetrics(&tmOld);
pDC->SelectObject(pFont);
pDC->GetTextMetrics(&tmNew);
pDC->SelectObject(&fArial);
pWnd->ReleaseDC(pDC);
long oldHeight = tmOld.tmHeight+tmOld.tmExternalLeading;
long newHeight = tmNew.tmHeight+tmNew.tmExternalLeading;
if (nFlag != CDF_NONE)
{
CRect clientRect, newClientRect, newWindowRect;
pWnd->GetWindowRect(windowRect);
pWnd->GetClientRect(clientRect);
long xDiff = windowRect.Width() - clientRect.Width();
long yDiff = windowRect.Height() - clientRect.Height();
newClientRect.left = newClientRect.top = 0;
newClientRect.right = clientRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;
newClientRect.bottom = clientRect.bottom * newHeight / oldHeight;
if (nFlag == CDF_TOPLEFT)
{
newWindowRect.left = windowRect.left;
newWindowRect.top = windowRect.top;
newWindowRect.right = windowRect.left + newClientRect.right + xDiff;
newWindowRect.bottom = windowRect.top + newClientRect.bottom + yDiff;
}
else if (nFlag == CDF_CENTER)
{
newWindowRect.left = windowRect.left -
(newClientRect.right - clientRect.right)/2;
newWindowRect.top = windowRect.top -
(newClientRect.bottom - clientRect.bottom)/2;
newWindowRect.right = newWindowRect.left + newClientRect.right + xDiff;
newWindowRect.bottom = newWindowRect.top + newClientRect.bottom + yDiff;
}
pWnd->MoveWindow(newWindowRect);
}
pWnd->SetFont(pFont);
CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD);
while (pChildWnd)
{
pChildWnd->SetFont(pFont);
pChildWnd->GetWindowRect(windowRect);
CString strClass;
::GetClassName(pChildWnd->m_hWnd, strClass.GetBufferSetLength(32), 31);
strClass.MakeUpper();
if(strClass==_T("COMBOBOX"))
{
CRect rect;
pChildWnd->SendMessage(CB_GETDROPPEDCONTROLRECT,0,(LPARAM) &rect);
windowRect.right = rect.right;
windowRect.bottom = rect.bottom;
}
pWnd->ScreenToClient(windowRect);
windowRect.left = windowRect.left * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;
windowRect.right = windowRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;
windowRect.top = windowRect.top * newHeight / oldHeight;
windowRect.bottom = windowRect.bottom * newHeight / oldHeight;
pChildWnd->MoveWindow(windowRect);
pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);
}
}
than on OnInitDialog() function
fArial.CreateFont(
16,
0,
0,
0,
FW_BOLD,
FALSE,
FALSE,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS,
_T("Verdana"));
fArial1.CreateFont(
13,
0,
0,
0,
FALSE,
FALSE,
FALSE,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS,
_T("Verdana"));
CPropertyPage* pPage = GetActivePage ();
ASSERT (pPage);
ChangeDialogFont (this, &fArial1, CDF_CENTER);
for (int iCntr = 0; iCntr < GetPageCount (); iCntr++)
{
VERIFY (SetActivePage (iCntr));
CPropertyPage* pPage = GetActivePage ();
ASSERT (pPage);
ChangeDialogFont (pPage, &fArial1, CDF_CENTER);
}
VERIFY (SetActivePage (pPage));
CTabCtrl* pTab = GetTabControl ();
ASSERT (pTab);
if (m_psh.dwFlags & PSH_WIZARD)
{
pTab->ShowWindow (SW_HIDE);
GetClientRect (&m_rctPage);
CWnd* pButton = GetDlgItem (ID_WIZBACK);
ASSERT (pButton);
CRect rc;
pButton->GetWindowRect (&rc);
ScreenToClient (&rc);
m_rctPage.bottom = rc.top-2;
}
else
{
pTab->GetWindowRect (&m_rctPage);
ScreenToClient (&m_rctPage);
pTab->AdjustRect (FALSE, &m_rctPage);
}
pPage->MoveWindow (&m_rctPage);
please help me for this.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I'm not wading through all that!
But I can imagine the problem. The wizard needs to calculate the size of the dialog before creation, so it can create itself first, large enough for your ends.
Reading the PROPSHEETPAGE structure, it has a PSP_PREMATURE flag. That implies that the normal behaviour is to wait until the correct tab / next button is pressed before the page is corrected.
I can see two choices:
1) Use the PSP_PREMATURE flag, and hope that makes the calculations work on the actual window, rather than reading the dialog template.
2) Load the resource into R/W ram, change the font field, and use the PSP_DLGINDIRECT flag of the PROPSHEEYPAGE. Not an easy choice...
Good luck,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
I want to use CToolBar in a doc/view based project. when i set corresponding images for the toolbar, i found that the height of the bottons is not as high as the toolbar. so, how to make them as high as its parent(ToolBar)?
If i implement it by ownerdraw, i fond, there would be more issues to deal.
Any ideas?
|
|
|
|
|
I noticed that there are some differences between MS C++ and C++ that is used elsewhere, for example most tutorials available on the internet are in "normal" C++.
Are the commands so differnt that you need to learn one or the other or are they similar enough that if you leanr one, you know both?
I'm currently stuck in a class about MS C++ nad I don't have any poosibility to learn the "normal" C++.
When I'm done (3 months) will I also be able to programm with the "normal" C++ or would I have to learn that again?
If so, how long would it take (realistically) to switch from MS C++ to the "normal" one?
Thanks in advance.
|
|
|
|
|
Microsoft simply provides certain extensions to the C++ standard.
These extensions are MS specific and will work only with MS compilers and OSs.
Don't worry about learning one over the other. They're almost the same.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
They are practically the same for almost all purposes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks.
Though I noticed in MS C++ you cannot use cin /cout , the syntax for #include is different and strings are also handled differenty.
|
|
|
|
|
Megidolaon wrote:
Though I noticed in MS C++ you cannot use cin/cout,
That's not true.
Megidolaon wrote: the syntax for #include is different and strings are also handled differenty.
That is, as well, not true.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i think cin/cout can be used in ms c++,once i tried.Maybe you didn't include the right head files.or some thing wrong with the name spaces
|
|
|
|
|
You can certainly use any cin/cout in ms c++, .. u have to include iostream.
kamalesh
|
|
|
|
|
Megidolaon wrote:
Though I noticed in MS C++ you cannot use cin/cout, the syntax for #include is different and strings are also handled differenty.
It's not that. In pre-standard C++, it would be like
#include <iostream.h>
After standardization its,
#include <iostream>
Moreover I can say you forgot to include "using namespace std".
|
|
|
|
|