|
hi peter, finally i've made it with visual c++ 6.0
but, this is will only success if i use windows XP as the operating system,
and failed when i try those in win2000pro or win 2000 server.
maybe i should told you that my irda device can only be attached to the usb, not to the serial port. so i can't use my code to send or recieve any information.
and maybe you can told me for the suitable path that i can use for accesing this usb irda device, instead of com3 that will only automatically show up (added to the com port list) when i beam my cellphone's irda in windows XP OS not to win 2000.
i have try what you told to write IRDAx as the path but this's failed
please help me
thank's very much!
note:
i also email you this post.;)
|
|
|
|
|
HI,
IrDA really implements a VIRTUAL serial port by means of its device driver, and it is also the device driver which is responsible for the device to be recognized by the OS, and XP has definitely more built-in drivers than previous OSs. Virtual means that an IrDA device can really be manipulated like a real COM port although it is not.
Since I dont have any real experience specifically with IrDA I suggest you to consult the device manufacturer's documentation.
Peter Molnar
|
|
|
|
|
Hi,
I have the following scenario:
class CFoo
{
public:
int Foo();
static CFoo * CreateFoo() { return new CFoo; }
};
void * GetNewFooHandle() { return (void *) CFoo::CreateFoo(); }
int FooFoo(void * fooHandle) { return ((CFoo *)fooHandle)->Foo(); }
I don't it done with the declarations (I played around with __cdecl / extern "C" etc.)
Any pointers? (Or a sample would be nice)
Flirt harder, I'm a coder.
mlog || Agile Programming | doxygen
|
|
|
|
|
what kinda of error are you getting.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
Sorry for the late reply - I got it working.
Error was function not found at linkage.
Found out that in a .cpp file, you can call CPP stuff even in an funciton that is declared extern "C"
So things look like this:
#ifdef __cplusplus
class CFoo { ... };
#endif
#ifdef __cplusplus
extern "C" {
#endif
void * FooCreate();
int FoFoo(void *);
#ifdef __cplusplus
}
#endif
CFoo * CFoo::CreateInstance() { ... };
int CFoo::Foo() { ... }
extern "C" void * FooCreate() { return (void *) CFoo::CreateInstance(); }
extern "C" int FooFoo(void * f) { return ((CFoo *)f)->Foo(); }
Cool!
I'm not sure if this is a VC6 only thing - but that shouldn't hurt me much
Flirt harder, I'm a coder.
mlog || Agile Programming | doxygen
|
|
|
|
|
Does C has classes?
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
No, so this will not compile. You have to put the code of the function that uses the class inside the .cpp file.
John
|
|
|
|
|
declaring extern C or not will only tells the compiler how to mangle the function the c++ way or the c way... nothing changes in its functionality.(yeah linking should be carefully done)
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
This will help you in accessing the static member function of C++ in C.
//Test1.cpp
#include <iostream.h>
typedef int (* pFunc) (int,int);
class D {
public :
static int Calculate(int iNum1,int iNum2);
};`
extern "C" {
int D::Calculate(int iNum1, int iNum2) { return iNum1 + iNum2; }
pFunc p = D::Calculate;
}
// Test.c
#include <stdio.h>
typedef int (* pFunc) (int,int);
extern pFunc p;
int main() {
int iResult = (*p)(10,20);
printf("Value is %d",iResult);
return 0;
}
Hope this will help you!
Regards
Dinesh
|
|
|
|
|
How to read and edit the id3 tag for a wma file?
There are functions in the windows media SDK to do it but this involves linking in to a pretty big library for what is a simple operation.
Does anyone know how to do this simply?
|
|
|
|
|
Hi Everybody,
Whenever i create an object of Derived CFrameWnd class, it doesn't have any view attached to it. Can I associate a CHtmlView class with Derived CFrameWnd class by calling SetActiveView ?
Is there any other way to attach the CHtmlView with the Derived CFrameWnd class, so that i should be able to display the dynamically prepared HTML in that Derived CFrameWnd object.
Regards
Dinesh
|
|
|
|
|
i've created a visual studio add in using the wizard.
i copied a method from other project (that i found here in code project) that retrieves the *.dsw file path.
here is the code:
CString CCommands::GetWorkspacePath()
{
CWinApp* pApp = AfxGetApp();
CString szWorkspace;
POSITION posdt = pApp->GetFirstDocTemplatePosition();
while (NULL != posdt)
{
CDocTemplate* pdt = pApp->GetNextDocTemplate(posdt);
if (0 == strcmp("CProjectWorkspaceDocTemplate",
pdt->GetRuntimeClass()->m_lpszClassName))
{
POSITION posdoc = pdt->GetFirstDocPosition();
if (NULL == posdoc)
break;
CDocument* pdoc = pdt->GetNextDoc(posdoc);
if (NULL == pdoc)
break;
szWorkspace = pdoc->GetPathName();
if (0 == szWorkspace.GetLength())
break;
}
}
return szWorkspace;
}
problem is that this line :
POSITION posdt = pApp->GetFirstDocTemplatePosition();
returns NULL for the postd. when i try this code in the other project it works ok
please, i already post this question before, and didn't get any reply
can any1 help me?
thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
you are getting Null value returned by
pApp->GetFirstDocTemplatePosition()
bcoz you are using the base class pointer, and the base class pointer in not aware your projects Doc Template positions. If you type cast it into your project's application class, it won't return null value;
CWinApp* pApp = AfxGetApp();
CString szWorkspace;
((MyPrjApp*)pApp)->GetFirstDocTemplatePosition();
never say die
|
|
|
|
|
thanks for the response, that didn't work!
here is what i wrote and i got still a null:
CWinApp* pApp = AfxGetApp();
CString szWorkspace;
POSITION posdt = ((CBackITUp_AddinApp*)pApp)->GetFirstDocTemplatePosition();
i even try the extern thing:
extern CBackITUp_AddinApp theApp;
.
.
POSITION posdt = theApp.GetFirstDocTemplatePosition();
that didn't work as well!!!
please please i need help
(try to create a new visual studio add in project in VC6, then try the lines above, you will get the same result.....i am doing something wrong, but i can't figure out what is wrong....
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
CWinApp* pApp = AfxGetApp();CString szWorkspace;//POSITION posdt = pApp->GetFirstDocTemplatePosition();POSITION posdt = ((CBackITUp_AddinApp*)pApp)->GetFirstDocTemplatePosition();
this code runs well when i executed it in newly created project. i executed this code in CMainFrame class message handler function.
i suggest you to try this code in CMainFrame Class for testing purpose only
the problem could be in base class of CCommons class, you haven't mentioned anything about its base class.
never say die
|
|
|
|
|
thanks for reply.
As I mentioned before, I am using a visual studio add in project the objects:
1. CBackITUp_AddinApp - the application
2. CCommands - the commands object
3. CDSAddIn - the developer studio add in object
4. ICommands - the commands interface
as you can see i am not using CMainFrame.....
I think I know what my problem is. the method GetFirstDocTemplatePosition will work only on the dev studio exe (the application which runs the add in) and not on the add in itself....
therefor when i am using
CWinApp* pApp = AfxGetApp()
I am getting a pointer to the add in (dll) main application object and not the exe main application object.....
now can you help?
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
according to me, you can solve the problem by creating a DLL project which has a fuction MyFunc() returning application object's address. Include this Dll in your addin and call MyFunc().
never say die
|
|
|
|
|
Hi,
I am not sure i follow, can you show me code on how to do that?
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hey Guys,
Yesterday I recompiled an MFC application in Visual C++.NET which had previously been built using VC6. Aside from a few casting issues, the compile seemed to work OK. However, the app will not execute. When I execute the app, the error I get is 0xC0000005: Access violation. The problem is that this exception is thrown before my app even gets into WinMain. The stack trace when the exception is raised is:-
<br />
NTDLL.DLL!_RtlRaiseStatus@4() + 0x24 <br />
NTDLL.DLL!_LdrpInitialize@12() + 0x15276 <br />
NTDLL.DLL!_KiUserApcDispatcher@20() + 0x7
When I take a look in the output Window after execution I get.
First-chance exception at 0x77f92373 (NTDLL.DLL) in WMSClient.exe: 0xC0000005: Access violation writing location 0x00000010.<br />
First-chance exception at 0x7c59ba9d in WMSClient.exe: 0x000003E6: Invalid access to memory location.<br />
First-chance exception at 0x77f92373 (NTDLL.DLL) in WMSClient.exe: 0xC0000005: Access violation writing location 0x00000010.<br />
First-chance exception at 0x77fb17a4 (NTDLL.DLL) in WMSClient.exe: 0xC0000005: Access violation.<br />
Unhandled exception at 0x77fb17a4 (NTDLL.DLL) in WMSClient.exe: 0xC0000005: Access violation.<br />
The program '[1968] WMSClient.exe: Native' has exited with code 128 (0x80).
At first I thought it was maybe caused by one of the global variables causing problems but most of them are basic types. Those which are classes, I put a breakpoint in the constructor but it never gets called.
Can anyone suggest anything else to look at?
Cheers
James
|
|
|
|
|
I will tell you one thingk vs.net is a junk at its best....
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
Hi !
In my application, I had to test many strings and (as the keyword 'case' is not usable for strings) I did something like this :
if (MyString==THIS_STRING)
{
}
else if (MyString==THAT_STRING)
{
}
else if (MyString==ANOTHER_STRING)
{
...
...
...
else
{
}
The problem is that I have to compare my string with more than 128 possible strings, and I discovered this morning that the compiler (Visual C++ 6) is not able to cope with more than 128 if's !!!!
Any idea on what would be a nice workaround for this limitation ?
Thanks !
Jerome
|
|
|
|
|
You could nest your Ifs, based in the first letter, then check for the second (and third...) letter in lower levels.
This way you can circumvent the limitation.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
It is the most simplest thing to do in programming live,
here it goes, create an array of all the strings taht you want to compare with,
then in a loop compare with each string and do appropriate action.(you can build your logic around this)
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
How about switch... case... statement?
Although to be honest I like the idea of strings' array better. Unfortunately, it's not mine. .
modified on Monday, November 29, 2010 6:02 AM
|
|
|
|
|