|
You are not sending the message anywhere. You need to send it to a specific window, and the pointer should be sent as a parameter; something like:
SendMessage(myHwnd, WM_SERIAL_OUTPUT, 0, (LPARAM)pointer);
where myHwnd is the window handle of your CPropertyPage . Then in your message handler you can recast the pointer and use it to access the object.
Veni, vidi, abiit domum
|
|
|
|
|
Richard ,
I must have muddied the water by using variable name "pointer".
I understand that the first parameter of the message is the handle to the message destination window, so I wanted to use "this" pointer of CProperyPage as such.
For now I am not concerned with the actual message parameters( WPARAM / LPARAM) until I get better understanding of the basic.
|
|
|
|
|
this is a pointer to the class object, not the window handle.
Veni, vidi, abiit domum
|
|
|
|
|
OK. but I should be able to pass it and access the class.
It sure looks as "this" cannot be passed as void*.
But passing "this->m_Hwnd" is OK.
|
|
|
|
|
No, you misunderstand both this and HWND .
this is the implied pointer of the current object. The HWND type is a handle to a Window object, but not to a class object, the two are totally different types. When sending messages between objects the general mathod is to use code of the form:
SendMessage(HWND windowHandle, MSG message, WPARAM wParam, LPARAM lParam);
In your program you wanted to send the pointer to your CpropertyPage object via a WM_SERIAL_OUTPUT message, which could then be used in the receiving window. So your sending code would be something like:
SendMessage(object->m_hWnd, WM_SERIAL_OUTPUT, 0, (LPARAM)this);
And your receiving code would be something like:
BEGIN_MESSAGE_MAP(CMyWnd, CWnd)
ON_MESSAGE(WM_SERIAL_OUTPUT, OnMyMessage)
END_MESSAGE_MAP()
...
LRESULT CMyWnd::OnMyMessage(WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(wParam);
CpropertyPage* prop = (CpropertyPage*)lParam;
return pC_SerialMFC->pC_SerialEx->Open(strPort, 0, 0, true, prop); }
Veni, vidi, abiit domum
|
|
|
|
|
So if I can send this->m_Hwnd why I cannot sent object "this" and retrieve its ( window) HWND in the called process?
But that is strictly academic now, I got it working using exactly what you have described.
Thanks for you help.
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: So if I can send this->m_Hwnd why I cannot sent object "this" and retrieve its ( window) HWND in the called process? You can, and I have twice shown you how to do it. I suggest you get hold of a book, or look for internet sites, on Windows programming, and read up on Windows message passing and handling.
Veni, vidi, abiit domum
|
|
|
|
|
Well, from your post I couldn't find out what do you do on which thread. Please send more accurate info. Maybe it would be more useful to describe what you want to achieve: a scenario where the user uses this functionality from beginning to the end.
|
|
|
|
|
Solved by passing this->m_hWnd
|
|
|
|
|
you can use SendMessage or PostMessage to send this pointer in same application only...
SendMessage(SENDER_HWND,WM_APP+1,0,(LPARAM)this);
at Receiving side Message callback
CPropertyPage *page = (CPropertyPage *)lparam;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Alok,
Ok, either I said it wrong in my OP or I just do not get it.
The doc clearly state the first parameter of Send/Post message is:
hWnd
[in] Handle to the window whose window procedure will receive the message.
You set the first parameter to SENDER_HWND but according to the doc it needs to be the receiver of the message and it works.
As of now I am not using the message WPARAM/LPARAM, just making sure I can get the message to the UI class.
I just need some clarification on this , please.
Thanks for you time.
Vaclav
|
|
|
|
|
I have a ClistView class, I am adding too many columns, 300+. At some point, the last few columns cannot be resized.
Is there a restriction on the number of columns or something to do with pixel sizes allowed?
Any help will be great.
Thanks,
Saleem
|
|
|
|
|
300+ columns? Who is ever going to be able to make head or tail of such a control?
Veni, vidi, abiit domum
|
|
|
|
|
Have you considered to use some grid control instead of list control ?
|
|
|
|
|
Md Saleem Navalur wrote: I have a ClistView class, I am adding too many columns, 300+. Rethink your design.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Try creating a simple CDialog based project with a CListCtrl, and then adding the same number of columns as in your example.
I often find that if I reduce the code to the simplest possible example then I can determine whether I've hit an internal Windows limit or some other part of my code is causing the problem.
|
|
|
|
|
Thanks for the reply.
I did. In the test sample too, same issue.
Created a standard MFC MDI app, with CListView as the view class.
And added this code in the OnInitialUpdate()
#define MAX_COL_COUNT 400
void CTestListViewView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
GetListCtrl().ModifyStyle(0, LVS_REPORT | LVS_SINGLESEL);
GetListCtrl().SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
LVS_EX_FULLROWSELECT);
CString data;
for(int i =0; i < MAX_COL_COUNT; i++)
{
data.Format("ColumnText_%d", i);
GetListCtrl().InsertColumn(i, data);
GetListCtrl().SetColumnWidth(i, 100);
}
for(int j =0; j < 5; j++)
{
for(int i =0; i < MAX_COL_COUNT; i++)
{
data.Format("Text_%d", i);
AddData(j, i, data);
}
}
}
void CTestListViewView::AddData(int row, int col, const char *str)
{
LVITEM lv;
lv.iItem = row;
lv.iSubItem = col;
lv.pszText = (LPSTR) str;
lv.mask = LVIF_TEXT;
if(col == 0)
GetListCtrl().InsertItem(&lv);
else
GetListCtrl().SetItem(&lv);
)<pre lang="c++">
|
|
|
|
|
Quote: 1.
Write C Programs to
a) Find the reverse of an integer value recursively.
b) Print all prime numbers less than N, where N is an integer given by the user.
Define and use a function prime(x) that checks if a number is prime or not.
c) Search for a Key in a 2D array. If the key is in the array, return its position also.
d) Read two unsorted list of numbers. Sort the lists individually and finally merge the two lists to form a single sorted list. Define and use function readlist(l) to read list l and sort(l) to sort the list l.
e) To read two square matrices and check whether multiplication of these matrices is commutative or not.
2. Write a menu driven C program to operate on Strings.
Menu:
Key
Action
**************************************************************
1 Print String Length
2 reverse string
3 convert all characters to lowercase
4 convert all characters to uppercase
Implement each action using User defined functions.
|
|
|
|
|
Short answer: No.
Longer answer: These forums are for people who want assistance with the code that they have written. They are not here for someone else to do your work or homework for you.
Veni, vidi, abiit domum
|
|
|
|
|
|
he/she is not alone.
Veni, vidi, abiit domum
|
|
|
|
|
See here.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Pick yourself up and write it! A degree in software engineering without background knowledge is less valuable then a roll of toilet paper. Such a degree helps you to get only positions like "seller in McDonalds"... Think about it and either start learning programming quickly or in case of disinterest towards software engineering find something else and change your profession/course.
|
|
|
|
|
Given a month and year, I want to write C++ code to determine what day of the week the month starts at. For example, for 2/2013, I want the code to return Friday (or an integer representing Friday) because February 1, 2013 was a Friday. The code needs to be portable. What is the best way to do this?
Thanks
Bob
|
|
|
|
|
Something like the following, with maybe a tweak or three:
struct tm time_in = { 0, 0, 0, 1, 7, 2013 - 1900 };
time_t time_out = mktime(&time_in);
struct tm *time_local = localtime(&time_out);
_tprintf(_T("%u\n"), time_local->tm_wday);
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|