|
For use of a dll on the C# you can use like this for example
[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd,
int Msg,
IntPtr wParam,
IntPtr lParam);
I dont know it was helpful for you?
|
|
|
|
|
Hello
I want to find a method to get the string width. When I surf internet, I find the function GetTextExtent() is available to get string width. I try it in my program use MFC based on SmartDevice(Wince), but the function is not supported in MFC.
Someone can kindly tell me which function is available to get the string width.
Thanks a lot.
Any suggestion is useful!! Thanks!!
|
|
|
|
|
sdhtyjnniutnbjnhbghb wrote: but the function is not supported in MFC.
It is supported on WinCE. Or do you mean something else ?
Prasad
MS MVP - VC++
|
|
|
|
|
That function is part of the SDK (C code) and is supported. What exactly do you mean by string width? I am assuming the width in pixels. If so then say so, but you will probably get directed to the same function.
By the way, regardless of what the MS documentations says the string output functions are not limited to 8192 characters. The limit is dependant on the number of pixels required to draw the string (the width).
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I am sorry for using the function in wrong way.
I want to paint string in AP and also to limit the range.
When I use the CString:: GetLength, I find it lsn't a good way to do it.
So I try to find a method to get the string width.
I use the GetTextExtent(string, string.getLength()) a moment ago and return CSzie.
I don't sure the CSize.cx value is pixels or not.
If it's true, maybe I can use the CSize.cx to limit the string number to paint in AP.
But are there more simple methods to do it??
Thanks a lot.
Any suggestion is useful!! Thanks!!
|
|
|
|
|
I am still not sure what you are asking, but ‘CSize.cx’ would be the width of the string in pixels. As far as I know there is no simpler method, although there are more complicated methods.
You can use the ‘GetTextExtent’ to determine the area you want to invalidate for drawing purposes, but I do not know what you mean by “limit the string number”.
‘GetLength’ returns the number of characters, provided it is not in Chinese or some other multi-byte language. That is if you are not using Unicode as the character type.
It has been a while but I have used ‘GetTextExtent’ and a few other methods while developing, for text editing and graphics string placement.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Because I will draw the string in the AP and the width is 251 in logical coordinates. If the string size are more than the width, I will add "..." to reply the words beyond the width. For example, if the string is "ABCDEFGHIJK" and I suppose that it is beyond the width, so I will show "ABCDEF..." in my AP.
I will try to use ‘GetTextExtent’ to get the string pixels and will to find transfer it in logical coordinates. I think it should be a good way to solve it.
Thanks a lot for your help.
Any suggestion is useful!! Thanks!!
|
|
|
|
|
What API are you using to paint the string? Maybe using one that clips the string will work...
Also, if supported, see GetTextExtentExPoint() which "retrieves the number of characters in a
specified string that will fit within a specified space..."
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Dear all
i just created a simple project using vc++ 2005 express edition, but after i built this project, one issue occurred. output showed :"cl : Command line error D8016 : '/MT' and '/clr' command-line options are incompatible". so what happened?
second issue: when i add one item: windows form. pc showed me:you are adding a CLR component to a native project.your project will be converted to have common project language runtime support. so what happened? thanks a lot.
i am looking forward to your news.
Li Zhiyuan
5/10/2006
|
|
|
|
|
If you want to use the .NET framework in your C++ app then you'll need to create a managed
assembly.
If you want a native Win32 application then you won't be able to use any CLR/.NET/managed code.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Dear all
i just created a simple project using vc++ 2005 express edition, but after i built this project, one issue occurred. output showed :"cl : Command line error D8016 : '/MT' and '/clr' command-line options are incompatible". so what happened?
second issue: when i add one item: windows form. pc showed me:you are adding a CLR component to a native project.your project will be converted to have common project language runtime support. so what happened? thanks a lot.
i am looking forward to your news.
Li Zhiyuan
5/10/2006
|
|
|
|
|
I have a DATE type variable and i am trying to display the date and time stored in it but i am not able to succeed. can anyone give me any suggestions? The date I am trying to display is in the form of FILETIME. Thanks in advance.
Regards,
Vijay.
God may not give us what we 'want', but he surely gives us what we 'need'.
|
|
|
|
|
Try FileTimeToSystemTime function.
|
|
|
|
|
Thanks. i had the problem solved immediately after i posted the question here.
fd0129002 wrote: Try FileTimeToSystemTime function.
yes, I used the same function. Thanks anyways.
Regards,
Vijay.
God may not give us what we 'want', but he surely gives us what we 'need'.
|
|
|
|
|
hi,
You can also use (in VC++, at least):
CTime time = CTime::GetCurrentTime ();
CString szEditTime = time.Format ( "%A, %d.%B.%Y, %H:%M:%S" );
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
hi i have to get the user login path ie c:\documents and settings\allusers in a system. how to do this
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
Try SHGetSpecialFolderPath function.
|
|
|
|
|
What is purpose of padding of 2-2 bytes in debug build??
What are other important differences in Release and debug builds??
Thanks & Regards,
Sandip.
|
|
|
|
|
SandipG wrote: What is purpose of padding of 2-2 bytes in debug build??
????
Steve
|
|
|
|
|
I am not sure what you mean. Usually the only reason for padding in debug is so that an overrun can be detected. I have seen that in the VC 1.52 and below compilers, but since VC6 and above have come out – I have not looked.
You will need to be more specific.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
There is padding of 2 bytes before and later after each variable in debug build.
What is this paddign for??
|
|
|
|
|
I would assume that they are used for detecting over-runs and under-runs by the debugger, so that a crash does not occur during debugging. Of course I do not know this for a fact and may be some else does. All I do know is one of my environments padded arrays in debug mode and it caught me off guard when runtime analyses showed I was short one byte, because the runtime was not padded. That, of course, was my fault, but the fault was hidden in debug mode.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
how to control parallel datapins to implement a circuit with led using window xp visual C++ ?? HELP PLZZ
any useful source code or website ??
|
|
|
|
|
Someone said that PostQuitMessage function does not really send a WM_QUIT message to the message queue of the calling thread. I wonder what does this function exactly do.
//Here is a simple test code
/*If PostQuitMessage function sends a WM_QUIT message to the message queue of the calling thread, GetMessage(..., hwnd, ..., ...) can't get the WM_QUIT message, the application won't leave the message loop.
But in this example:
1.compile the source ;
2.Ctrl+F5 to run it;
3.D&D to move the window;
4.press the corss to close window;
5.found that the application process disappear from the "task manager "
It seems that GetMessage(..., hwnd, ..., ...) got the WM_QUIT message.
Someone said it's because of that PostQuitMessage is called before DestroyWindow.
But I can't get the same result when debugging by F5.
Sorry for my poor English......thanks for your attention.
*/
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
BOOL bRet = FALSE;
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="Weixin2003";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls);
HWND hwnd;
hwnd=CreateWindow("Weixin2003","CreateWindow",WS_OVERLAPPEDWINDOW,
0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while((bRet = GetMessage(&msg,hwnd,0,0)) != FALSE)
{
/*if(bRet == -1)
{
break;
}*/
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
DWORD dwCurThreadID = GetCurrentThreadId();
switch(uMsg)
{
case WM_CHAR:
break;
case WM_LBUTTONDOWN:
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,"WM_PAINT",strlen("WM_PAINT"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
PostQuitMessage(0);
//DestroyWindow(hwnd);
break;
case WM_DESTROY:
//PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
|
|
|
|
|