|
|
Hello,
I just switsched from C++ 6.0 to VS .NET, and some code that compiled before does not compile any more:
CString cNum = "123";
unsigned short* ss;
DWORD dwRet = (DWORD)wcstod(cNum.GetBuffer(0),&ss);
error C2664: 'wcstod': conversion of parameter 1 von 'ATL::CSimpleStringT<basetype,t_bmfcdll>::PXSTR' into 'const wchar_t *' impossible
What do I have to do? I do NOT want to use the .NET framework nor ATL, only MFC? I suppose I have to switch some compiler parameters?
Thanks a lot!
Martin
|
|
|
|
|
Assuming you're doing a Unicode build, the GetBuffer() call is unnecessary. The first param to wcstod() is a LPCWSTR , and CString has a conversion operator that will be called automatically.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | NEW~! CP SearchBar v3.0 | C++ Forum FAQ
Ford, what's this fish doing in my ear?
|
|
|
|
|
Thanks a lot, due to your answer i was able to get the code compiling now. I thought new .NET projects were unicode by default, as i could not find a switch. but now i found it and it works fine.... i appreciate it very much, thanks....
Martin.
|
|
|
|
|
Although you already have an answer to the CString -related issue, I note that you are using wcstod(...) instead of wcstoul(...) .
I could understand if you might be handing strings that contain values in the higher ranges of the double type, but you are truncating them via the cast to DWORD ...
Passing an unsigned short type as the second parameter to the wcstod(...) function might be technically incorrect now, too; it should be wchar_t , as wchar_t is (can map to) a native type in VC++ .Net and above (see __wchar_t for details).
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi,
hope somebody can help me with this question:
I'm writting a BHO that needs to be aware of user actions with mouse in explorer window. Most of the work is done easily using elementFromPoint to retrieve html element under current cursor position. However I've got a hard time with combo boxes within the page. I cannot find a way of getting what the user has selected (expanding the menu and clicking on an item).
Messing around with spy++, I found out that whenever a selection is made, the TridentCmboBx class receives a CB_GETCURSEL request and responds with the actual selection. Which is exactly what I need. However this is not sent to Explorer_Server class, nor any other explorer window I can track through spy.
So what I'm asking is, does anybody have any more info on this? MSDN states vaguely that the msg is sent to "interested application".
I guess another solution would be to hook/subclass the combobox to get the messages my self, but if there's a page with many combos then its hard whereas if the msg is sent to a window i already watch like Explorer_server this would save me the trouble.
Thanks in advance.
petevam
|
|
|
|
|
I just thought of something that might do the job. I'm thinking about sending the CB_GETCURSEL to the combo myself each time I need it. Sounds simple. Will need to get the handles to all combos in the page though.
-- modified at 14:38 Thursday 6th October, 2005
But then again, how do I know when I need it? There's the catch.
|
|
|
|
|
Could anyone please tell me how to define and use an "enum" (i.e., UDT) within ATL7? That is, within the .h file rather than the .idl file. I am doing this:
[<br />
uuid("09GGGB2E-BA1D-4349-900A-DA8F5B8DD24C")<br />
] <br />
enum OmniTrackerCommands<br />
{<br />
kOTC_Startup = 0, <br />
kOTC_Query = 1<br />
} OmniTrackerCommands;<br />
<br />
[<br />
object,<br />
uuid("F17B0F10-6FF5-4C14-A4A8-C513ACGGGE4A"),<br />
dual, helpstring("IDataTransmitter Interface"),<br />
pointer_default(unique)<br />
]<br />
__interface IDataTransmitter : IDispatch<br />
{<br />
[id(1), helpstring("method Send")] HRESULT Send([in] OmniTrackerCommands command);<br />
};
and I am getting a compilation error C2061: syntax error : identifier 'OmniTrackerCommands'.
Any help would be greatly appreciated.
|
|
|
|
|
[id(1), helpstring("method Send")] HRESULT Send([in] enum OmniTrackerCommands command);
|
|
|
|
|
Hi,
I am using Led Library (Text Control) which is wrappers on MFC in the form of template classes.
I want create Control (or Ocx) from the View class of this library.
I tried using ActiveX wizard as well as ATL.
But not getting visual effect of OCX as we will get when we build ocx from CEdit.
How can i DO IT?
Thanks in advance
-Hemant
|
|
|
|
|
Hi,
I am using Led Library (Text Control) which is wrappers on MFC in the form of template classes.
I want to build from the View class of this library
|
|
|
|
|
While compiling a project in which i am using WTL i am getting the following error
i:\hcl\cybertrace\KT-docs\ct-code-personal\CT Ver1.2\Client\CtShell\wtl71\\include\\atlctrls.h(1833) : error C3861: 'ImageList_Read': identifier not found, even with argument-dependent lookup
What should i do for that.
Sunil Virmani
|
|
|
|
|
Take a look at your commctrl.h include file or if NOIMAGEAPIS is #define d. If it doesn't contain the function prototype, chances are that your platform sdk is of ancient origin.
--
|
|
|
|
|
What are the limitations of using an ATL? Can a regular program (of course w/o GUI) be implemented as an ATL including calling a function inside the same .cpp, using structs, CStrings, MFC functions, etc? Thanx
|
|
|
|
|
Hi,
I have MFC static library Led Lib which is editor library.
I want to implement the View class of this library as Control using ATL COM?
Tried but not getting the actual Picture?
How can I do it?
Thanks in advance
-Hemant
|
|
|
|
|
what are .tlh files?
could anyone give me the links for COM tutorials?
thanx in advance
|
|
|
|
|
nvamshi wrote:
could anyone give me the links for COM tutorials?
http://www.codeproject.com/com/[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
.tlh and .tli files are created automatically by the compiler when you #import typelibraries. The .tlh file contains the "header" part, and the .tli file contains the "implementation" part, should you generate dispatch wrappers and stuff like that. These files are injected automatically into the code by the compiler, so you don't have to worry about them.
--
Look straight into the light!
|
|
|
|
|
I know the composite control is implemented by CWindowImpl.I think i can get the HDC of the control and operate it.but always occur an error.
my code as follow(in control class):
HDC hdc = GetDC();
LPSTR lpText = "hello world";
::TextOut(hdc,0,0,lpText,lstrlen(lpText));
ReleaseDC(hdc);
I use this control in ie.the code can execute successfulLy.but an error report will gave when i close the ie.error message:Microsfot Internet Explorer met an question and need to be closed...
the same thing happened when i operate the contained control in the dialog.
HDC hdc = ::GetDC(GetDlgItem(IDC_xxx));
::TextOut(hdc,0,0,lpText,lstrlen(lpText);
ReleaseDC(hdc);
I don't know if i say it clearly.thanks all.
|
|
|
|
|
Hi,
My problem is the follow one:
who to know, everything that I will go to describe will be about OPOS(Ole Point-of-Service)
I have many Automation Controllers. There are many ocx.
These ocxs are the Control Objects to an specific device( like CashDrawer ). The Control Object make calls to methods that are implemented in a Service Object. Each device or device class has a Service Object. This Service Object can be ATL or MFC.
I need to know how do I have to create a projec in Visual c++ 6.0 to build a Automation Server(Service Object). What steps do i have to do? Like what kind of Server type( Dynamic Link Library, Executable or Service), which check box do I have to check( allow merging of proxy, support MFC and/or support MTS) or
which ATL Object do I have to insert in project?
To show an example, the CrashDrawer's Control object defines the fallow method:
long COPOSCashDrawer::GetOpenResult()
{
long result;
InvokeHelper(0x31, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
How do I have define the Service Object to answer that method? I really dont't know how to do that. Please i need your help!
Grateful!
Hélio
|
|
|
|
|
if we return a sigle value, its fine, but if u wanna send a structure?
for example, i want to send,
[code]
typedef struct
{
BSTR Name;
long num;
double d;
}st;
[code]
how to send this across?.. how to define in "Add method" dialog?
in VB i guess we can accept using "Type"
[vb code]
private Type TestType
Name as string
num as long
d as double
end type
[/vb code]
can we do like ,in add-method [int z,[out,retval]st xyz] ??
will this work?
V
|
|
|
|
|
First create the UDT in IDL. There are examples in the MSDN docs on how to do it. They're very similar to ordinary structs in C/C++. Make sure the UDTs are referred to in the library block of the IDL file, so that VB gets the needed type information.
Then you just type in "struct YourUdtName" in the type box in the add method dialog. If you want, you can make a typedef in the IDL code like typedef struct tagYourUdtName { ... } YourUdtName; . Then you can type "YourUdtName" in the type box in the add method dialog.
--
Keep talking! I'm the preacher, you're a fool.
|
|
|
|
|
|
Did it work out well for you? (I still feel a bit ashamed for the ATL wizard stuff )
--
Look straight into the light!
|
|
|
|
|
actually, it could be done using Type in VB itself, no need to create an UDT in the Component. the requirement was like that. eg:
[ATL]
Fire_Event(BSTR Num,long Num)
[/ATL]
[VB]
Public Type MyType
Name as String
Num as long
End type
[/VB]
so in the client app, i assigned it like
MyType obj
Private ob_newEvent(String Name,Long num)
ob.Name = Name
obj.num=num
End sub
so i didn't find the need. But the terror strikes again,... soon i'll have to get these arguments in the method itself just like we did with Events.i'll try it at that time..so we'll meet again very soon.
[sorry for delay, just now i clicked on ATL ]
V
|
|
|
|