|
So the simplest way to use GetClientRect ... and example
RECT clientScrRect;
GetClientRect(hWnd, &clientScrRect);
Instead hWnd write HWND of your controls. Finally you got coordinates of your controls.
|
|
|
|
|
Hello everyone,
I'm hoping someone can point me in the right direction with a little project I'm working on!
I have a collection of third-party C-style DLLs that I am using in my own UNmanaged C++ DLL. My goal was to wrap these functions into my own DLL and then write a VB6 COM based DLL to wrap my C-style DLL so that I can use these functions in a VBScript ASP page. Whether or not this makes sense, I've done this before and had good success, so I was going to try it again.
However, the third-party C-style DLLs are returning Unicode strings, and I actually NEED to support multiple languages. When I pass these Unicode strings to the VB6 app, they'll be converted to the ANSI character set for the locale of the IIS server (i.e. char* rather than wchar_t*), so presumably they will be converted to some Western European ANSI character set. I'm not sure how the .ASP page will handle passing the strings to/from the VB6 COM DLL wrapper, but I'm guessing it will be a straight Unicode call, so there is probably not a conversion problem there, but maybe I'm wrong about that!
Maybe I could handle the conversion of Unicode->ANSI (wchar_t -> char) myself, using the appropriate codepage for the user's language, and there also seem to be some workarounds using VarPtr or StrPtr to pass Unicode between VB6 and C++.
At this point, I'm pretty sure I could hack out some solution, but I was really looking for an elegant/"correct" way to handle this. I don't have much experience with the .NET solutions like ASP .NET, but I would be open to writing the small web page that I will need as a frontend in whatever language/framework is most appropriate.
Basically, I need to have a web page that is capable of calling these third party unmanaged C++ DLLs and to receive and display the results on a web page in multiple languages. Is (C++ DLL->ANSI)<-->(ANSI->Unicode->VB6 COM DLL->Unicode)<-->.ASP an appropriate way to go? Is there a better way than wrap my C++ DLL in the VB6 COM DLL? Should I use a .NET wrapper (using PInvoke, from what I've seen) on the third-party DLLs and use ASP .NET to call the managed .NET wrapper directly? Not sure exactly how to do that, so if that's a good choice, any pointers appreciated.
Thanks for your help!
Corey
|
|
|
|
|
Just a general piece of advice: if at all possible, stay with UNICODE. There are 'round trip' problems with multiple string conversions.
|
|
|
|
|
Thanks, Gary, I will try to avoid the conversion by using some information that I found on Microsoft's site: http://support.microsoft.com/kb/205277[^]. It looks like I can pass the strings back to VB6 without conversion with a little wrangling.
I guess that my post was a bit wordy, but the question I'm really trying to answer is what is the best way to access unmanaged C++ DLLs (without source code) from an ASP or ASP .NET page, knowing that some of the parameters are Unicode wchar_t's. The VB6 COM DLL wrapper I'm planning on using seems to be a little cumbersome, but I think it will work!
Thanks again!
Corey
|
|
|
|
|
I can't do this initialization in OnCreate because the ActiveX control isn't ready yet ( its methods fail ).
I usually do this in OnIdle with a boolean value to make sure I did it only once, but CView doesn't have OnIdle. What's the best way to do this?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Try to do this in OnInitialUpdate .
|
|
|
|
|
In getA, I can get 1-dimension array.
But in getB, it will appear the error message as below:
Error 2 error C2440: 'return' : cannot convert from 'int [3][2]' to 'int **'
int* getA()
{
int a[2];
return a;
}
int** getB()
{
int b[3][2];
return b;
}
|
|
|
|
|
Why bother? Returning a temporary would trouble you anyway.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
akira32 wrote: In getA, I can get 1-dimension array.
The first thing here is that you're not "get[ing] 1-dimension array." you're returning the address of the first element of where a 1 dimensional array was before the function returned. Depending on what you do with the pointer after the function returns you could crash your program or even leave it with a big security hole.
The bad news is that you can't return an array of any sort directly from a function. The slightly better news is that you can return a structure containing an array, e.g:
struct array_wrapper
{
int data[10];
};
struct array_wrapper get_array()
{
struct array_wrapper a;
a.data[5] = 100;
return a;
}
Quick caveat: I don't program in C anymore so I may have got the syntax a bit wrong.
Cheers,
Ash
Edited to fix slightly knackered code formatting
modified on Friday, May 14, 2010 5:54 PM
|
|
|
|
|
Both these calls leave you with memory leaks. If you want to allocate arrays to be returned from a function you should use one of the memory allocation functions, malloc() or new .
It's time for a new signature.
|
|
|
|
|
Hi,
Sorry to sound picky but it's important for C programmers to understand these things...
The original functions the original author posted didn't leak anything (well, the one that would have compiled anyway) - all the memory allocated for his arrays on the stack were cleaned up when the functions returned.
The problem he would have caused was actually the reverse of a leak: continuing to access memory that's been marked as inaccessible for some reason. This is usually called a "dangling pointer" as it's pointing somewhere it shouldn't. In this case it's pointing to a block of memory on the stack and writing to it could cause all sorts of fun and merriment.
Cheers,
Ash
|
|
|
|
|
You shouldn't be returning an array, the best thing is to accept a pointer to an array allocated by the caller (plus dimensions) and then fill it. That way you'll avoid the problem of who has to do the cleanup of the memory. For example this function will fill the array with random values:
int foo (int* dstArr, int m, int n)
{
for (int i=0;i<m;i++)
for (int j=0;j<n;j++)
dstArr[i*n+j] = rand();
}
int main()
{
int arr[3][5], arr2[10][10];
foo((int*)arr, 3, 5);
foo((int*)arr2, 10, 10);
}
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|
Hi all,
This project is using C++ with MFC with Visual Studio 2005.
I'm converting over an old WinCE project which used to use SHSipPreference and some keyboard dlls called NumSip and AlphaNumSip which essentially popped up a virtual keyboard on the PDA.
I'm trying to find something similar for WinXP that I can use instead. I need an ability to control the keyboard from within the program, tell it when to pop up and close, etc.
Aside from just writing a virtual keyboard from scratch (which would work fine but I don't have a lot of time to do this), does anyone know of an existing API/lib/code or anything that does this already?
Thanks!
KR
|
|
|
|
|
Hi I am using writeprivateprofilestring function to update two files.
Suppose Two files are A.ini and B.ini.
First we call writeprivateprofilestring for A.ini by and After
call writeprivateprofilestring for B.ini. Both file value update successfully.
but after call writeprivateprofilestring for b.ini and system is being restart then
Only second file B.ini value is update but A.ini value is not updated
|
|
|
|
|
shivanandgupta wrote: Both file value update successfully.
How are you verifying this?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
function do well.
but in case power restart then first value is not updated
but second value is updated.
|
|
|
|
|
Hi all,
i m using Rapi function ro connect with Windows based mobile phone.
but after analysis i found this function generate problem in handling of CFilDialog,
when i use CFileDialog with Rapi function than some times CFileDialog crash with AccessViolation error.
if i use CFileDialog without Rapi Functions,than its working fine in same conditions and situations.
please help me,and provide me guidance for this.
thanks in advance.
|
|
|
|
|
Le@rner wrote: please help me,and provide me guidance for this.
You should better use your debugger for this purpose. This will give you way more information than what we could.
|
|
|
|
|
Its not crash when i run it from code,its generate problem when i run application from exe.
|
|
|
|
|
Obviously having this work under a true cross platform umbrella is beyond the topic of this message. Right now I'm curious on just how hard or if anyone has been successful in taking some of the most excellent MFC controls found here and converted them to work under wxWidgets. I'm particularly interested in the XListCtrl since that is basically a control that always wows me and I feel having something like available under wxWidgets would be awesome.
I'm not asking that others do it for me, I'm just curious on if anyone has tips on where to start first and the best method to tackle it. If it's not possible or requires to completely re-invent the wheel, then maybe it's a bit over my head.
Thanks!
|
|
|
|
|
I've been playing with wxWidgets for a year or so now but mostly just to have a GUI interface for testing my machine vision tools. I used MFC for a long time before. It should be possible to do it since it's all just programming and there seems to be a very high correspondence between MFC message handlers and the handlers in wxWidgets.
I'm not familiar with the control you mentioned but a potential problem is where the MFC class is just a wrapper for a Window's control. In that case if you're looking for a truly cross platform solution, then it gets a lot tougher since the underlying control won't exist on other platforms or if a similar control does exist, you'll have to do essentially multiple implementaions under the covers to make it transparent at the top level.
MFC being Windows specific allows you get get to and use the underlying Windows API pretty easily and depending on how much that has been done may cause problems, too.
The wonderful thing about the Darwin Awards is that everyone wins, especially the members of the audience.
|
|
|
|
|
Hello;
I am a student in software engineering. I should do a project that is maze.
a game in console32 mode that define with an 20*40 array. walls and blocks in this game should be given as an input. a 2 character worm should start from a place and finish the game in another place. This program should have a timer.
CAN ANYONE HELP ME ?!?!?
<<<i've no="" word="" to="" express="" my="" seep="" gratitude="" from="" anyone="" who="" help="" me="" in="" this="" hard="" work="">>>
|
|
|
|
|
What is your trouble about? What have you done so far? Please ask specific questions.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: What have you done so far?
Are you new around here? He has copied his homework assignment to this forum, just like all the others do, like it or not. Now, can you finish it by Monday morning? it is due in the second period.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|