 |

|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|

|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|

|
A dialog based program, I put a function to draw a string on the screen. the function is member function of TestDlg.h;
But if I put the function in TestDlg.cpp, the screen show some weird messy characters.
Then I put the same function in another cpp file, most of this file are global functions. JTest.cpp, with Jtest.h.
Weird thing is it works, screen can show correct characters.
Situation like:
TestDlg.cpp
IMPLEMENT_DYNAMIC (CTestDlg,CDialog)
...
void TestDlg::DrawInfoLabel(void)
{
CDC* pDC;
CRect rect(562,448,688,467);
CString lebelStr;
HDC hDC;
LOGFONT lf;
HFONT FontNew, FontOld;
pDC = GetDC();
hDC = pDC->GetSafeHdc();
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = -14 * GetDeviceCaps(hDC,LOGPIXELSY)/72;
lf.lfWeight = 0;
WCHAR lffn[] = TEXT("FZYaoTi(OpenType)");
wcscpy(lf.lfFaceName,lffn);
lf.lfCharSet = GB2312_CHARSET;
FontNew = CreateFontIndirect(&lf);
FontOld = (HFONT)SelectObject(hDC,FontNew);
pDC->SetTextColor(RGB(0xFF,0x00,0x00));
SetBkMode(hDC,TRANSPARENT);
DrawText(hDC,_T("??"),-1,rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
SelectObject(hDC,FontOld);
DeleteObject(FontNew);
ReleaseDC(pDC);
}
In JTest.cpp
void TestDlg::DrawInfoLabel(void)
{
....
}
Every line is same, only difference is file name. I feel it is the following statement affect the screen output.
IMPLEMENT_DYNAMIC (CTestDlg,CDialog)
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
#include "afxres.h"
#include "newres.h"
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#endif
#ifdef APSTUDIO_INVOKED
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"#include ""newres.h""\r\n"
"\0"
END
........
The above is .rc file.
Hope someone can explain that.
Thanks in advance
|
|
|
|

|
Hi,
This sounds like it might be related to code inline expansion. Where are you calling the function DrawInfoLabel() ? Are you calling this from the WM_PAINT handler?
Best Wishes,
-David Delaune
|
|
|
|

|
I call that function just in a general member function.
CTestDlg
{
public:
void refreshInfoLabel(void);
}
void CTestDlg::refreshInfoLabel(void)
{
DrawInfoLabel()
}
|
|
|
|

|
Hi,
It is generally not recommended to draw outside of the WM_PAINT/WM_ERASEBKGND handlers. When you draw outside of WM_PAINT you need to invalidate the window rectangle/region so that the subsystem knows to redraw it.
InvalidateRect function[^]
InvalidateRgn function[^]
Best Wishes,
-David Delaune
|
|
|
|

|
I wonder if WM_PAINT message handler could display messages immediately.
or even I draw it in a member function, it would refresh in OnPaint() executed?
|
|
|
|

|
econy wrote:
I wonder if WM_PAINT message handler could display messages immediately.
or even I draw it in a member function, it would refresh in OnPaint() executed?
No. There is no guarantee that when your WM_PAINT message fires that the subsystem will redraw window contents unless the rectangle/region/window is marked invalid. This is an OS optimization to prevent excessive redrawing. (However with DWM enabled[^] the rules do change a bit)
Read all of this so that in the future you can help others: Painting and Drawing[^]
Best Wishes,
-David Delaune
|
|
|
|
|

|
I am confused with SetFont() function.
I followed example code in MSDN, it works well in my laptop.
but, when I same code in my WinCE program, it dont work, font not change, show [] [] [] []
LOGFONT lf; CEdit *pEdit1;
lf.lfHeight = 12;
lf.lfWidth = 0;
memset(&lf, 0, sizeof(LOGFONT)); WCHAR lffn[] = TEXT("Simsun(OpenType)");
wcscpy(lf.lfFaceName,lffn);
lf.lfCharSet = GB2312_CHARSET;
if (m_font2.m_hObject) {
m_font2.DeleteObject();
}
m_font2.CreateFontIndirect(&lf);
pEdit1 = (CEdit *) GetDlgItem( IDC_EDIT1 );
pEdit1->SetFont(&m_font2);
SetDlgItemText(IDC_EDIT1, _T("公里") );
Appreciate any suggestions
|
|
|
|

|
Hi,
The code you pasted here appears to be bugged:
pEdit1 = (CEdit *) GetDlgItem( IDC_EDIT1 );
SetDlgItemText(IDC_INFO_PL, _T("公里") );
Best Wishes,
-David Delaune
|
|
|
|

|
Changed. it is solved, but I don't know the reason. please refer to another question I posted.
|
|
|
|

|
Hi, in a dialog project member function, the results of retGetRect() confused me:
void CTestDlg::RefreshLabels(void)
{
CRect rect;
CEdit1 *pEdit1 = GetDlgItem(IDC_EDIT_TST1);
pEdit1->GetRect(&rect);
}
with breakpoint, I got
[tagRECT] = {top=350682312 bottom=15026448 left=15026448 right=784660}
|
|
|
|

|
Solved, it need to use GetClientRect(); then ClientToScreen()
|
|
|
|

|
Hi everybody!
I'm creating a program which use database.
My problem is: I use ExecuteSQl() to input data into my database but when i run it, I show an error "too few parameters. Expected 1".
CString path(_T("\',\'")), pathInt(_T("','"), rien(_T("NUL"));
reqPer = _T("insert into personne values (2014,\'") + nomPer + path + prenPer + path + datNaissPer + path + liNaisPer + path + domPer + _T("\',") + rien + _T(",\'") + numPiecPer + path + _T('M') + path + profPer + path + natPer + _T("\',") + rien + pathInt + rien + _T(")");
database.ExecuteSQL(reqPer);
|
|
|
|

|
You should check the final value of the reqPer string to see whether the SQL command is correctly formed. I would also strongly suggest you do not create SQL statements in the way you have done, as this leaves your code open to SQL injection, and the potential loss or corruption of your database. See the CRecordSet class[^] for the correct way to do it.
|
|
|
|

|
I saw it, but it's not very clear for me. Please, can you post a sample?!
|
|
|
|

|
Fawaz Ajani wrote: Please, can you post a sample? Sorry, I don't have one. You need to either search for yourself, or spend time reading the documentation.
|
|
|
|

|
It will be correct, if i use this one?
sql.Format("INSERT INTO NomTable (Colone1,Colonn2, ....) VALUES(%d ,'%s','%s', ....)",m_Variable1,m_Variable2, ....);
db->ExecuteSQL(sql);
|
|
|
|

|
This article does not do any writing or updating, but it may help to point you in the right direction.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|

|
if a window be hidden,then does it still get messages from windows?
i.e, it's message loop still get/dispatch messages?
|
|
|
|

|
Yes, to both.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|

|
As already stated by the other user, yes. This is actually a common trick people use for getting a message pump wherever they need one, make an invisible window that can be messaged to.
|
|
|
|

|
Hi, I want to change several CEdit's font in a dialog based program. the dialog is a non-modal dialog,in it's OnInitDialog().
BOOL CTestFontDlg::OnInitDialog()
{
CFont * pFontNew;
LOGFONT lf; CEdit *pEdit1;
CEdit *pEdit2;
CEdit *pEdit3;
CDialog::OnInitDialog();
pApp = (CTestFont*) AfxGetApp();
AddFontResource(TEXT("\\FlashDisk\\Startup\\Simsun.ttc"));
if ( pApp->g_Settings.language == LNG_CHINESE ) {
lf.lfHeight = 12;
lf.lfWidth = 0;
memset(&lf, 0, sizeof(LOGFONT)); WCHAR lffn[] = TEXT("Simsun(OpenType)");
wcscpy(lf.lfFaceName,lffn);
lf.lfCharSet = GB2312_CHARSET;
pFontNew->CreateFontIndirect(&lf);
pEdit1 = (CEdit *) GetDlgItem( IDC_INFO_PL );
pEdit2 = (CEdit *) GetDlgItem( IDC_INFO_PRESS );
pEdit3 = (CEdit *) GetDlgItem( IDC_INFO_TOP );
pEdit1->SetFont(pFontNew);
pEdit2->SetFont(pFontNew);
pEdit3->SetFont(pFontNew);
}
return TRUE;
}
but once I added the if ( pApp->g_Settings.language == LNG_CHINESE ) { ... } block,
the screen become black, nothing be displayed.
modified yesterday.
|
|
|
|
 |
|