|
Yes it is. That's why I'm worried about it.
Do you have any idea...
I appreciate your help all the time...
Eranga
|
|
|
|
|
str.c_str() gives you a const char *
Given
char * msg;
do std::string m = (std::string) msg;
|
|
|
|
|
But still it gives only the first letter.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: But still it gives only the first letter.
That's because you are confused between Unicode and ANSI strings. All of the letters are there, but you are using the Watch window incorrectly. Try appending ,su to the variable.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This is interesting at all. Thanks for the tip
I appreciate your help all the time...
Eranga
|
|
|
|
|
Errr, is it possible that your problem is upstream?
Are you sure that pInMsg->message is actually a char * ? And are you sure it points to more than one char?
try:
char *c = "hello";
std::string str = "boo";
str = "woot";
str = c;
And use the debugger to look at c and str at different stages. If that all works as you'd expect, then you'll just have to have a nap and look again at your code.
Do you have a unicode / not unicode mixup, some parts use TCHAR and you've just not told us it all?
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Iain Clarke wrote: Are you sure that pInMsg->message is actually a char *? And are you sure it points to more than one char?
100% sure that is, because I make it....
I appreciate your help all the time...
Eranga
|
|
|
|
|
I didn't think it would take you long to verify it!
I was more interested in the little code I put in the pre section - if that works as expects, then either you have an error in the initial variables going to your real code, or you have the debugger / watch windows set up badly.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
I have not ventured inot DLL before.. i want to know if somebody can give me some documents on DLL.. like how to create a simple DLL. any links.. so that i can go thru it and learn more about it.
thanks
|
|
|
|
|
Click Here ->[^]
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
hey thanks for the documents...
|
|
|
|
|
I am not sure if this is the exact topic to post here however I thought I'd give it a try.
I have been coding MFC for a few years.
The look and feel of the GUI's (that I create ! ( Dialog based app) seems ( to me ) to look very ordinary .
Sometimes when you demo stuff to customers , part of the deal is to create "Flash" like GUI's that actually have the same functionality of an engineering application ( normally coded using MFC, C++). Customers most often get "wowed" by the new , cool , look and feel instead of the usual gray dialog with buttons and edit boxes.
I am in search of something ( library / component(s)) that can still preserve the ease of coding in MFC/C++ but exposes a whole new world of creating stunning GUI ( rich in color and action ).
I would appreciate if someone could provide ideas for achieving this .
Engineering is the effort !
|
|
|
|
|
There are loads of nifty looking controls on a certain website full of code articles... Gradient coloured bubble buttons, all sorts.
I will warn you though - when you venture into Nifty, you usually take a huge detour through Hideous.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
I m working on VC++2005 MFC,an my project on SDI,so i use view class.
actually i m working on audio-video splitter,
here this problem occur in video window where i play video file it is a animate control.
so when i shift application video cant repaint.
anyone can tell me how can repaint the views?
thnks
modified on Wednesday, February 13, 2008 4:02 AM
|
|
|
|
|
You can call CWnd::Invalidate() in your view class to repaint the view.
|
|
|
|
|
thanks dear
i call this but it is not working.
|
|
|
|
|
Hi,
I found an interesting problem with a simple task.
I was adding a context menu to a tree view embedded on a dialog and the dialog is embedded on the main window.
I was using GET_X_LPARAM and GET_Y_LPARAM from windowsx.h
The value returned from GET_X_LPARAM is incorrect (negative) within the WM_NOTIFY section but the GET_Y_LPARAM is ok.
Of course the problem is easily solved by using GetCursorPos but has
(1) Anyone else seen this?
(2) Anyone else can replicate this?
(3) Can someone tell me why this is the case?
Upon looking at the WM_NOTIFY docs is it correct that LPARAM is getting overridden with the
NMHDR structure? So it actually is behaving correctly and it's just by change that the y member is correct and happens not to be overridden?
Regards,
Flip
|
|
|
|
|
From the docs...
WM_NOTIFY
The WM_NOTIFY message is sent by a common control to its parent window when an event has occurred or the control requires some information.
WM_NOTIFY
idCtrl = (int) wParam;
pnmh = (LPNMHDR) lParam;
So, yes, LPARAM needs to be cast to a NMHDR *. You then look at pNMHDR->code to look at what kind of notify it is, and then look up the docs for that one.
If you're adding a right click handler to a tree view, then you want to handle the NM_RCLICK code. That *just* sends the NMHDR structure, which has no position information embedded in it.
In which case, GetCursorPos or GetMessagePos (GetMsgPos?) are your only ways to go.
Success,
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Yup, I thought as much when I read the docs before I posted. Thanks Iain.
I am doing exactly that. I an handling NM_RCLICK and using GetCursorPos();
Prior to that I was adding a context menu to a static window using WM_RBUTTONDOWN with the afforementioned macros. I was just expecting (incorrectly) that would work for all context menus.
Evidently it is better to just use GetCursorPos.
Also if it helps anyone else I could not catch the message properly until I used this
int id = TrackPopupMenu(hh,TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,pt.x,pt.y,<br />
0,h,NULL);
id returns the menu item resource id that was selected
Does anyone know of a way to catch the message without using the TPM_RETURNCMD ?
I know for a top level menu its
WM_COMMAND
and a switch on
LOWORD(wParam)
Regards,
|
|
|
|
|
It bugs me that that the NM_CLICK & NM_RCLICK notifications don't have a cursor position in an extended NMHDR too. It just feels clumsy to get it separately.
I would recommend GetMessagePos rather than GetCursorPos. I've been caught out in the past by a breakpoint before the getcursorpos, moving the mouse and getting the "wrong" value.
-----
As for trackpopupmenu, the window h would get a WM_COMMAND with a lParam of the menu item id of the selected menu unless you specify TPM_RETURNCMD. As that would have to mesh in with the main menu commands of my application I always use TPM_RETURNCMD anyway. Keeps local commands to local definitions. No worrys about my popup in one part of my app clashing with the numbers for another.
The TPM_NONOTIFY flags turns off messages (eg) WM_MENUSELECT from being sent, etc.
Another error you may have had. The NM_RCLICK gets sent to the dialog window - but did you use the dialog's or the treeview's window handle for the hWnd param of TrackPopupMenu? Maybe you were handling the WM_COMMAND message in the wrong window? You could check by using spy++ and monitoring all windows in your app for WM_COMMAND.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Good tip re GetMessagePos - I will use it from now on.
Your were exactly right with regards to NM_RCLICK. I was using the incorrect handle.
Now it works with or without using the notify message in TrackPopupMenu. - Thanks.
Previously I was using spy++ and seeing the WM_COMMAND message but obviously that was getting eaten by the treectrl as that did not have its own message pump.
On another track with things that bug me about the w32 API (apart from all of it ) is the following.
Editing labels on trees using TVN_ENDLABELEDIT the following is necessary
to get the line length
allocate a string based on line length
set the first byte to the line length
pass resulting string to get the entire line which overwrites
the string with the actual desired data
<br />
HWND e = TreeView_GetEditControl(h);<br />
int len = SendMessage(e,EM_LINELENGTH,NULL,NULL);<br />
TCHAR *s = new TCHAR[len];<br />
*((LPWORD)s) = len;<br />
SendMessage(e,EM_GETLINE,NULL,(LPARAM)s);<br />
I suppose GetWindowText could be used but what a crazy API.
Regards,
|
|
|
|
|
That's a crazy was because you're not reading the documentation for TVN_ENDLABELEDIT...
The lParam of a WM_NOTIFY message points to a NMHDR structure. But this can be embedded as the first member of a different structure.
Looking at TVN_ENDLABELEDIT, it sends a TV_DISPINFO structure, who's beginning part looks a LOT like a NMHDR structure.
To get the text:
void CBusEdit_Commands::OnDeviceEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
TV_DISPINFO *pTVDispInfo = (TV_DISPINFO*)pNMHDR;
*pResult = FALSE;
if (pTVDispInfo->item.pszText == NULL)
return;
if (SomeFunctionInMySoftware (pTVDispInfo->item.pszText))
*pResult = TRUE;
}
Good luck,
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
I have put a picture control box on a MFC dialog window. How can I get the coordinate of the picture control box?
|
|
|
|
|
Code something like this:
HWND hwndControl = ::GetDlgItem(GetSafeHwnd(), IDC_PICTUREBOX);
ASSERT(hwndControl);
CRect rec;
VERIFY(::GetWindowRect(hwndControl, &rec));
VERIFY(::MapWindowPoints(NULL, GetSafeHwnd(), reinterpret_cast<LPPOINT>(&rec), 2) != 0);
Steve
|
|
|
|
|
I'm trying to pass a pointer to struct between a C++ DLL and a C# app, both of which I'm writing. The code below compiles and runs, but the C++ pointer does not seem to be copied to C#. I've simplified the code for ease of reading. I think I need to use MarshalAs and have tried it out but either I can't get it to compile or doesn't work. Any help that can be offered is greatly appreciated. Thanks!
My C++ DLL has the following declarations:
struct record {
char name[32];
}
__declspec(dllexport) void get_name(record *record_to_get);
void get_name(record *record_to_get)
{
record_to_get = local_unmanaged_record;
}
Here is my C# code:
public class Win32
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct record
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string name;
};
[DllImport("my_cpp.dll")]
public static extern void get_name(ref record record_to_get);
}
In another class, I have:
Win32.record test_record = new Win32.record();
get_name(ref test_record);
Console.Writeline("record data = {0}", test_record.name); // Nothing is printed
|
|
|
|