|
Sorry,
my fault again
that's why test is not a CString.
Cstring str;
GetDlgItem(IDC_...).>GetWindowText(str);
sprintf(sql,"INSERT INTO %s table VALUES ('auto','%s','','te')",table, str.GetBuffer(str.getLength()) );
tip: have a look at MSDN at the members of CString
Heiko
|
|
|
|
|
i get the following compilation problem in the following code:
-------------------------------------------------------------------------------------------------
class CXFaceRecognitionDlg : public CDialog
{
// Construction
public:
CXFaceRecognitionDlg(CWnd* pParent = NULL); // standard constructor
// TODO:Why compilation error goes here??
CStatusBar GetStatusBar(){ return m_wndStatusBar; }
protected:
HICON m_hIcon;
CStatusBar m_wndStatusBar;
-------------------------------------------------------------------------------------------------
d:\documents and settings\lim ming wee's pc\my documents\yccheok\xfacerecognition\xfacerecognitiondlg.h(29) : error C2558: class 'CStatusBar' : no copy constructor available
i solve it by changing the statement from
CStatusBar GetStatusBar(){ return m_wndStatusBar; } ==>
CStatusBar& GetStatusBar(){ return m_wndStatusBar; }
and solve the problem.
however, i have no idea what is the cause of this problem. can anyone tell me why?
thank you.
regards
yccheok
|
|
|
|
|
As the compiler said:
no copy constructor available
You cannot create a new CStatusBar instance from an existing one. You must either use references (as you have done it) or pointers.
So
CStatusBar bar1;
CStatusBar bar2 = bar1; would fail. Correct is
CStatusBar bar1;
CStatusBar *bar2 = &bar1;
...
anyfunction(*bar2, ...);
But remember, if you change bar2, bar1 changes too.
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
i just move from c to c++ recently and have no idea on the causes of the following compilation problem (i am using visual c++ 6.0).
=======================================================================
// FaceDlg.h
#include "Picture.h"
class CFaceDlg : public CDialog
{
// Construction
public:
CFaceDlg(CWnd* pParent = NULL); // standard constructor
void SayHai(void);
=======================================================================
// Picture.h
class CFaceDlg;
class CPicture : public CStatic
{
// Construction
public:
CPicture(CFaceDlg* parent);
CFaceDlg* m_pParent;
=======================================================================
// FaceDlg.cpp
BOOL CFaceDlg::OnInitDialog()
{
// ... wizard generated initialization code ommited...
// TODO: Add extra initialization here
m_pPicture = new CPicture(this);
return TRUE; // return TRUE unless you set the focus to a control
}
=======================================================================
// Picture.cpp
CPicture::CPicture(CFaceDlg* parent)
{
m_pParent = parent;
//??? m_pParent->SayHai();
}
=======================================================================
The following code compile no problem. however, when i try to uncomment out
m_pParent->SayHai() in CPicture constructor, i get the following error:
D:\Documents and Settings\Lim Ming Wee's PC\Desktop\Face\Picture.cpp(20) : error C2027: use of undefined type 'CFaceDlg'
d:\documents and settings\lim ming wee's pc\desktop\face\picture.h(12) : see declaration of 'CFaceDlg'
D:\Documents and Settings\Lim Ming Wee's PC\Desktop\Face\Picture.cpp(20) : error C2227: left of '->SayHai' must point to class/struct/union
Error executing cl.exe.
can anyone tell me how to solve this problem?
thank you.
regards
yccheok
|
|
|
|
|
I find it easier to let the class wizard make my dialog boxes than to code them by hand.
|
|
|
|
|
In FaceDlg.cpp #include "FaceDlg.h" .
In Picture.cpp #include "Picture.h" .
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
I have a strange problem. I create a toolbar on my mfc application and I load a bitmap with buttons.
My buttons are red but when the toolbar apears the buttons are almost black, like the brightness has been reduced
to almost 5%.
The code looks like this.
UINT buttons[3] = {ID_ADD,ID_NEWS,ID_OTHER_VIEW};
if (!m_wndToolBar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadBitmap(IDB_MY_TOOLBAR) ||
!m_wndToolBar.SetButtons(buttons,3))
{
TRACE0("Failed to create myToolBar\r\n");
return -1;
}
m_wndToolBar.SetSizes(CSize(37,36),CSize(30,30));
Does anyone have any idea? I've look through MSDN but I didn't find anything related to this.
Thanks.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
the code like this:
UINT MyThread(LPVOID){
while(1){
::SendMessage(lParam->m_hWnd, WM_MYMESSAGE, 0, 0);
sleep(100);
}
return 0;
}
void A::Fun1(){ //this function will be called frequencily (eg. 10ms)
m_count++; //the member variable;
}
void A::Fun2(){ //this function receive the WM_MYMESSAGE message;
i=m_count;
m_count--;
~~~~~~~~~~~~ if there is only one A object, it's right;
but if there are two or more A objects, some of
them will wrong, the m_count will always 0 in
Fun2(),why?
thank's for you help.
}
.
|
|
|
|
|
Hmm, it's quite difficult to say from the source you provided m_count is a member of A, I assume.
Did you ever call the Fun1() for the second instance? Or it is just always called only for the first one? This would be probably the reason I guess.
|
|
|
|
|
yes, m_count is a member of A,
i call every A instances's Fun1(), but not every one can work,
some of them maybe wrong. but this matter is not allways happened.
I use them like this:
CDlg1 has a A instance m_first;
CDlg2 has a A instance m_second;
I add the CDlg1 dlg1, CDlg2 dlg2 in a TabCtrl;
normally the m_first and m_second can work.
but sometime the m_first maybe wrong, and sometime the m_secodn
maybe wrong.
.
|
|
|
|
|
then I'd put the following trace to the Fun1() as well as to the Fun2() . You should see diffenent numbers - you will see exactly what is stored in m_count in different instances. This could help to define the next debugging steps.
<br />
TRACE( "instance 0x%08X called, m_count = %d\r\n", this, m_count );<br />
|
|
|
|
|
One reason the design does not work is because there is no synchronization. Threads and processes must be synchronized.
Kuphryn
|
|
|
|
|
to geo_m:
thank you for your help, i add the TRACE in the Fun2(),then
i find one of the A instance create the thead failed;
When i call AfxBeginThread(), it return 0, so some A do not work.
thank you very much.
.
|
|
|
|
|
to geo_m:
thank you for your help, i add the TRACE in the Fun2(),then
i find one of the A instance create the thead failed;
When i call AfxBeginThread(), it return 0, so some A do not work.
i call it again, it's ok!
but i don't understand why it will fail.
.
|
|
|
|
|
In a DLG based app,I want to draw something on a CONTROL (static) and there are some another CONTROL on the Dialog.
I Get the DC of the Static control and draw something on it,but failed.I see nothing on the static control.So I delete the sentnce
CDialog::OnPaint()
And then,all of these control except the staitc can't be seen.(they are not being paint)
I want to paint the Static control but hope the other control will draw it themself!
How can I do?
Thank you for your help!
Don't look at me in that way!
|
|
|
|
|
from the MSDN under GetDlgItem, changed to be a CStatic, assuming you are using the MFC
// uses GetDlgItem to return a pointer to a user interface control
CStatic* pStatic;
pStatic= (CStatic*) GetDlgItem(IDC_STATIC1);
pStatic->SetWindowText(_T("Hello world"));
<HR SIZE=1 /HR>
<i>If I have seen further it is by standing on the shoulders of Giants.</i> - Isaac Newton 1676
|
|
|
|
|
I just want to draw a picture on it!
exmaple:
I want to draw some lines on the static control!
when I do this ,nothing can be seen in the control.
Don't look at me in that way!
|
|
|
|
|
I am working from memory here.
In that case the best method, I think, would be to subclass the control.
Or you could try get the CDC of the static control, using my #1 method and use this to paint, also add the paint logic into the OnPaint. BUT the control may decide to paint it it's slef therefore overwriting what you have put there! I use this method to place a bitmap into a static control.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Thank you! I got it!
Don't look at me in that way!
|
|
|
|
|
My program needs to execute a function when an the internet become available (ie. Dial-up connection established ...) How do I get this event?
Msn messenger automatically logs in when the internet becomes available, but I haven't been able to figure out how it catches the event.
|
|
|
|
|
Use a 30 second Timer to call InternetGetConnectedState.
Jason Henderson My articles
"The best argument against democracy is a five-minute conversation with the average voter." - Winston Churchill
|
|
|
|
|
|
I have made several attempts to retreive data from the registry and it has not worked. I have been using code from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppc2k/html/ppc_stry.asp and it hasn't been working for me. Could anyone tell me what is wrong with their code, particularly the LoadPreferences() function they posted. I would really appreciate any help.
-- Steve
|
|
|
|
|
Okay here is a down and dirty way to read a registry setting. This has worked great for me for years.
<br />
HKEY hKey;<br />
char szProductType[80];<br />
DWORD dwBufLen;<br />
int i;<br />
<br />
<br />
RegOpenKeyEx( HKEY_LOCAL_MACHINE,<br />
"SOFTWARE\\SomeRegKey\\SomeSubRegKey",<br />
0, KEY_QUERY_VALUE, &hKey );<br />
RegQueryValueEx( hKey, "SomeRegValue", NULL, NULL,<br />
(LPBYTE) szProductType, &dwBufLen);<br />
<br />
i = atoi(szProductType);<br />
RegCloseKey( hKey );<br />
<br />
return i;<br />
I'm basically reading in a value from the registry that was saved as a character and changing it to an int and returnig that int to the calling function.
Hope this helps
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
That code really helped me. I was trying to store a string and load a string from the registry, but the modifications weren't that hard. Thanks! I can finally use the windows registry in a meaningful way for my applications!
-- Steve
|
|
|
|