|
//Dll Code
extern "C" __declspec(dllexport)void CommonBinFrame(char Scanfile, float Elstmod[25]);
float Poisson[] = {0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,
char Scanfile[_MAX_PATH]; 0.3};
void CommonBinFrame(char Scanfile, float Elastmod[25])
{
//some code//
new_header_out(Elastmod);
//some code//
}
void new_header_out(float Elastmod[25)
{
//some code//
for(count=0;count
|
|
|
|
|
Well, if the CommonBinFrame function is expecting an array with 25 elements, then I guess all is well.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
peoria123 wrote:
extern "C" __declspec(dllexport)void CommonBinFrame(char Scanfile, float *E);
void CommonBinFrame(char Scanfile, float E[])
{
}
Float E[]= only have 1st array element
I'm not sure what that is supposed to be but it does not look like valid code. You also have a separate issue that your function definition declares its first parameter as a char rather than a char* . It should rather be something like:
extern "C" __declspec(dllexport)void CommonBinFrame(char* Scanfile, float *E);
void CommonBinFrame(char* Scanfile, float *E)
{
printf("%s\n", Scanfile);
for (int i = 0; i < 25; ++i)
{
printf("item[%d]: %6.2f\n", i, E[i]);
}
}
<div class="signature">Veni, vidi, abiit domum</div>
|
|
|
|
|
I have a hierarchy of classes processing serial (COM port) data.
The UI is CpropertyPage ( in main thread) and the port data is retrieved by a COM port thread.
It all works, sort of.
Two “problems” ,related.
I would like to be able to receive error messages from each stage and need to pass the data received back to the CpropertyPage.
I thought that I could use Post/Send messages to do this, but I cannot figure out how to pass the CpropertyPointer “down the line”.
Here is the first working attempt snippet:
In CpropertyPage class :
SendMessage(WM_SERIAL_OUTPUT); // message received in CpropertyPage OK
CString strTest = this->strFrequency; // just checking OK
lResult = pC_SerialMFC->pC_SerialEx->Open(strPort, 0,0,true,this ); // OK
Here is the first “down step” and it fails
LONG C_SerialEx::Open (LPCTSTR lpszDevice, DWORD dwInQueue,
DWORD dwOutQueue, bool fStartListener, void* pointer )
{
TRACE("\nOpen port %s using base class ",lpszDevice ); // Call the base class first
CString strTest = pointer.strFrequency; // compiler error – see below
SendMessage((HWND) pointer, WM_SERIAL_OUTPUT,0,0); // no message received - I did not use Spy to trace where it went
left of '.strFrequency' must have class/struct/union type
So – how do I pass CproperyPage “this” pointer down the line ? Or is this approach all wrong?
Any constructive help would be greatly appreciated.
Cheers Vaclav
|
|
|
|
|
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
|
|
|
|
|