|
By default CWnd defined in afxwin.h. You should find same definition CWnd* m_pMainWnd;
|
|
|
|
|
hi I am trying to use it in InitDialog() but they are showing undeclared identifier m_pMainWnd
I saw this variable in the afxwin.h which is included by the StdAfx.h
|
|
|
|
|
What version of Visual Studio do you use? If 2010, there is another structure of default generated code. Anyways check that stdafx.h is include in your header file
|
|
|
|
|
hai , I am using this code in InitDialog()
int width=GetSystemMetrics(SM_CXSCREEN);
int height=GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(AfxGetApp()->m_pMainWnd,0,0,width,height,SWP_SHOWWINDOW);
It is not working.
|
|
|
|
|
hey i got it .
I chaged the last parameter to SWP_NOZORDER|SWP_SHOWWINDOW .then it was working.
Thank u
|
|
|
|
|
|
On some multiple-monitor systems this only maximizes the window to one of the monitors, which may or may not be what the original poster wanted.
|
|
|
|
|
As the answers aboves, I want to ask a question for more. That is:
How can you let the buttons or text controls to suit the screen when the dialog fit the different screen size?
In another word, the buttons in dialog will stay unmove if you just let the dialog fit the screen, that will make the whole dialog look grotty.
Thanks, I wonder if I describe the question clearly.
|
|
|
|
|
At first you should determine controls position and form size, then on WM_SIZE event change position of controls that will depends on width and height of your form.
|
|
|
|
|
which functions can i use to do this?
|
|
|
|
|
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
|
|
|
|