|
When i programming with directx, seem i can't not use intellisense. So it't hard to remember the params.
May you help me.
|
|
|
|
|
Do you have two copies of Visual Studio open? That can stop Intellisense working.
The tigress is here
|
|
|
|
|
Hi, I get the problem again.
Thank to everyone help me!
My problem is that I have a pointer_to_function as member of my class. But I can't use this pointer to point to one of my member functions. More detail: I wrote a code like this:
int global_display(){
cout<<"global_display()"<
|
|
|
|
|
The syntax for member function pointers is rather confusing. If you want to get your code compiling so as you can call 'display_1', try:
int global_display(){
cout<<"global_display()"<<endl;
return 0;
};
class test{
public:
test();
int (test::*myfun)();
int display1();
int maindisplay();
};
int test::display1(){
cout<<"display1()"<<endl;
return 0;
};
int test::maindisplay(){
(this->*myfun)();
return 0;
};
test::test(){
myfun = &test::display1;
};
The main changes: firstly the constructor should not return 'int'. Then, the member function's declaration has to change to show it's a member function and not a non-member function. The invocation also has to change to use the ->* operator (or .* if you were calling a reference, in this case the object itself is calling, so we have to use this->*). Finally, the function reference has to be bound with the ampersand, and the classname too. This code was tested in VS2005 and VS2003.
Matt Godbolt
Engineer, ProFactor Software
StyleManager project
|
|
|
|
|
Hi i have added a dialog box and sone buttons like ok button to it. i want the ok button to be disabled when the dialog box is initially displayed.how do i do this
sud
|
|
|
|
|
Try this bit of code.
BOOL CYourDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//pointer to your button
CButton *pButton = (CButton*)this->GetDlgItem(IDC_BUTTON1);
pButton->EnableWindow(FALSE);
}
EvScott
|
|
|
|
|
EvScott wrote: BOOL CYourDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//pointer to your button
CButton *pButton = (CButton*)this->GetDlgItem(IDC_BUTTON1);
pButton->EnableWindow(FALSE);
}
Thanks for ur response. when i entered the above code i got a warning
"warning C4005: 'IDC_SIZE' : macro redefinition
see previous definition of 'IDC_SIZE'"
Please tell me what is wrong
Thanks
|
|
|
|
|
Compiler Warning (level 1) C4005
'identifier' : macro redefinition
The given identifier was defined twice. The compiler used the second macro definition.
Sudeep, observe the above which is an excerpt from MSDN. Make sure that you have only ONE identifer named "IDC_SIZE". The compiler will complain otherwise. Hope that this helps
EvScott
|
|
|
|
|
EvScott wrote: Compiler Warning (level 1) C4005
'identifier' : macro redefinition
The given identifier was defined twice. The compiler used the second macro definition.
Sudeep, observe the above which is an excerpt from MSDN. Make sure that you have only ONE identifer named "IDC_SIZE". The compiler will complain otherwise. Hope that this helps
idc_size is defined using #define only once. pls tell me where else can this declaration be found? i tried but cudn't get the solution
Thanks
|
|
|
|
|
Hi sudeep_br,
I suggestion that you change IDC_SIZE to exmaple IDC_SIZE2
and run again?whats happen?
-- modified at 2:10 Monday 10th April, 2006
and
m_yourButton.EnableWindow(0)
|
|
|
|
|
|
BOOL ProjectName::OnInitDialog()
{
CDialog::OnInitDialog();
GetDlgItem( IDC_Button )->EnableWindow(FALSE);´
}
|
|
|
|
|
sheshidar wrote: BOOL ProjectName::OnInitDialog()
{
CDialog::OnInitDialog();
GetDlgItem( IDC_Button )->EnableWindow(FALSE);´
}
Thanks for ur response. when i entered the above code i got a warning
"warning C4005: 'IDC_SIZE' : macro redefinition
see previous definition of 'IDC_SIZE'"
Please tell me what is wrong .where shud i make changes
sudeep
|
|
|
|
|
The easiest way is to check the "Disabled" box in the resouce editor.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Thought I had this done, realised I would be sending strings as well and have had major trouble making it happen. I am trying to use a DLL I wrote in VC6 to send a string, via callback, to a VB app I wrote in VB6. Below is the code I am using on both the DLL and VB projects.
DLL Side:
extern "C" void __stdcall stat( void (*cb) (char**) )
{
char* nrMsg = "This is a test!";
cb( &nrMsg );
}
VB Side:
Declare Sub stat Lib "mydll.dll" (ByVal funcptr As Long)
'
Sub CallbackFunction(ByRef numb As Long)
Form1.Label1.Caption = "Success: " + Str(numb)
End Sub
Output:
Success: 268486828
I know I have to convert it to BSTR Unicode, but do not know how or what includes are needed. Not exactly sure how to pull that data in on the VB side either. All information I have seen thus far was all theoretical, so an example would be great concerning both sides (i.e., DLL and VB sides). I will eventually need to pass around 12 strings and 12 integers at one time.
If you need more info, let me know. Thanks in advance
Best Regards
|
|
|
|
|
|
Hey, thanks a lot for showing me your guides. I never new that Japanese users could have problems with certain code, even though it works perfectly for English users. Also, never knew that strings in C are an array of chars. Good information, well written. Still I have questions and need some help building an example. Here is my effort, which doesn't work.
#include <atlconv.h>
void Baz ( BSTR* pbstr );
extern "C" void __stdcall stat( void (*cb) (char**) )
{
using std::string;
USES_CONVERSION;
LPCWSTR wsz = L"Test this is.";
BSTR bs1;
bs2.Attach ( W2BSTR(wsz) );
cb ( bs1 );
SysFreeString ( bs1 );
}
I think I am just confused, because here is the compile errors and warnings:
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(48) : error C2065: '_ASSERTE' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(122) : error C2065: 'LPCOLESTR' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(122) : error C2146: syntax error : missing ')' before identifier 'x'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(122) : error C2433: 'ocslen' : 'inline' not permitted on data declarations
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(122) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(122) : error C2143: syntax error : missing ';' before '{'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(122) : error C2447: missing function header (old-style formal list?)
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(123) : error C2143: syntax error : missing ';' before '*'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(123) : error C2433: 'OLECHAR' : 'inline' not permitted on data declarations
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(123) : error C2501: 'OLECHAR' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(123) : error C2061: syntax error : identifier 'LPOLESTR'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(123) : error C2501: 'ocscpy' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(123) : error C2065: 'dest' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(123) : error C2065: 'src' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(123) : warning C4508: 'ocscpy' : function should return a value; 'void' return type assumed
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(124) : error C2143: syntax error : missing ';' before '*'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(124) : error C2433: 'OLECHAR' : 'inline' not permitted on data declarations
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(124) : error C2501: 'OLECHAR' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(124) : error C2086: 'OLECHAR' : redefinition
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(124) : error C2061: syntax error : identifier 'LPOLESTR'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(124) : error C2501: 'ocscat' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(124) : warning C4508: 'ocscat' : function should return a value; 'void' return type assumed
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(125) : error C2146: syntax error : missing ';' before identifier 'T2COLE'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(125) : error C2433: 'LPCOLESTR' : 'inline' not permitted on data declarations
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(125) : error C2501: 'LPCOLESTR' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(125) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
Could someone take a look at what I have and show me what I have done wrong? I really need an example, never been a good non-hands-on learner. Thanks in advance.
best regards
-- modified at 22:03 Saturday 8th April, 2006
EDIT: Fixed to show include.
|
|
|
|
|
Your code sample doesn't make sense, but it looks like you're not using BSTR correctly. You also appear to not have the ATL or OLE headers included, so that's giving you the majority of the compiler errors. Start simple:
BSTR bs = SysAllocString ( L"Hello Bob" );
SysFreeString ( bs );
bs = NULL;
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
I used #include <atlconv.h>.. was that not right? What is the name of the includes I need?
thanks in advance.
-- modified at 1:21 Sunday 9th April, 2006
EDIT: I took another look at the second guide and figured out what I needed to do. Thanks a lot for the all the help. This is solved.
best regards
|
|
|
|
|
Hi borono,
Still having problems? Have a look here[^]. This function will allow you to convert a char* which is a C string to a BSTR.
Maybe there are better methods of doing this from VB though.
|
|
|
|
|
I believe I have found the answer you are looking for right here[^]. Now if you don't have this up and working by the end of the day I am personaly going to come and steal your computer
|
|
|
|
|
haha, no worries. I do have it working, here is what I did.
DLL Side:
#include <comdef.h>
template< class T >
BSTR ToBSTR( T a_Str )
{
return( _bstr_t(a_Str).copy() ) ;
}
extern "C" void __stdcall stat( void (*cb) (u_short**) )
{
char dao[100];
sprintf(dao,"UDP: %d",udp);
BSTR l_Temp = ToBSTR(dao);
BSTR bs = SysAllocString ( l_Temp );
cb( &bs );
SysFreeString ( bs );
bs = NULL;
}
VB Side:
Declare Sub stat Lib "mydll.dll" (ByVal funcptr As Long)
'
Sub CallbackFunction(ByRef numb As String)
Form1.Label1.Caption = numb
End Sub
works great! computer saved.
best regards
-- modified at 10:37 Sunday 9th April, 2006
EDIT: thought it would be a good idea to include the conversion function, considering without it, this code is useless. Bold represents the modificiation.
|
|
|
|
|
borono wrote: haha, no worries. I do have it working,
Damnit, I just put my shoes on too. Congrats, you spent long enough on this, now you can move onto the next problem :P
|
|
|
|
|
haha, how'd you know I'd be having a problem? I am, but it is all design. This I really am horrible with. When it comes to design, you will see many programmers all designing their GUIs pretty much the same way. Not because there is a lack of creativity but because it works. There is indeed, at least, three ways to accomplish anything. They have found the first, I am concerned with the latter.
best regards
|
|
|
|
|
Hello!
In my program I have something like this:
<br />
volatile stop;<br />
<br />
void SetStop()<br />
{<br />
stop = true;<br />
while (stop) Sleep(100);<br />
}<br />
<br />
while (true)<br />
{<br />
if (stop) <br />
{<br />
stop = false;<br />
return;<br />
}<br />
Sleep(10);<br />
}<br />
But while the main thread waits for the
variable stop to be reset, this never
happens! Why not?
If I don't wait for it, the program opens
a message box (which sais that the thread
was not stopped; by use of a CSingleLock),
and when it is open, the thread resumes...
Alex
|
|
|
|