|
Thanks Roger,
The function is to be static because, i am calling this process function in a thread. How to pass the LPVOID parameter to this process function??
|
|
|
|
|
Static member data need to be defined outside the class declaration. You can declare the CPortController member variable as static.
static CPortController m_myportcontroller ;
In the CSampleDlg cpp file, define the static variable as
CPortController CSampleDlg::m_myportcontroller;
Vini
|
|
|
|
|
The thread controlling function can be a non-static member of the class.
When you spawn the new thread with e.g. AfxbeginThread, you should pass the this-pointer as the LPVOID parameter. Your thread controlling function takes a LPVOID as argument which would now be your this-pointer. Type cast it and you'll be able to access both non-static member variables and functions from your thread.
Joe Newcomer has written a very nice article about threading that I strongly recommend everyone who is doing multithreading. You'll find it here[^]. He's got a lot of very useful tips, tricks and how-to's on his site.
When you're done with the threading stuff, a new problem may occur depending on how your ActiveX works. If you plan to use COM objects from a thread you have to initialize COM for that thread by a call to ::CoInitialize or similar. This sets up a new apartment. Now you have another problem: you can't cross apartment boundaries without marshalling the COM interface. Have a look at ::CoMarshalInterThreadInterfaceInStream and ::CoGetInterfaceAndReleaseStream for info about how to do that.
This is the correct way to do this. You have to marshal the interface. There are no shortcuts.
Post again if you have more troubles. If they are COM/ActiveX related, post your query in the COM forum.
Hope this helps
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
Thanks Vini,
i implemented , but getting comple errors. Can u specify in more detail???? please!!!
|
|
|
|
|
What are the compile errors you are getting? Specify the exact error messages, if possible.
Vini
|
|
|
|
|
We have a structure that we declare to be __declspec(allocate)'d into a particular section that we, earlier, declare with #pragma section(). This structure is never referred to by name, it is accessed by traversing the section itself.
When this structure was in our main program it was accessible. Now that I have moved it out into another library it is not. It appears that the linker has dead-stripped the symbol because it has determined that it's never getting used. I would like to be able to tell the linker to actually keep it.
Is there a keyword / link option I can use to do this?
|
|
|
|
|
hi,
Can i customize the ListCtrl Tabs & Move them when a costomize scrollbar Moves.
vinod c s
Integral Softech
|
|
|
|
|
vinivc wrote: Can i customize the ListCtrl Tabs & Move them when a costomize scrollbar Moves.
Well I didn't get you. What do you mean by ListCtrl tabs. Can you be more specific.
Nibu thomas
Software Developer
|
|
|
|
|
Hi vinivc ,
What's Tabs in the CListCtrl
|
|
|
|
|
hi,
Thanks for showing intrest in solving the problem.
I mean the ListLctrl Column header(i.e the Tabs which represent the column Header ).
I want to Customize them & use a customised HScroll & Vscroll to move the
contents of ListCtrl.
"(CListCtrl class in MFC)"
|
|
|
|
|
vinivc wrote: I want to Customize them & use a customised HScroll & Vscroll to move thecontents of ListCtrl.
They are known as HeaderCtrl and MFC equivelent class is CHeaderCtrl
vinivc wrote: I want to Customize them & use a customised HScroll & Vscroll to move thecontents of ListCtrl.
get the Pointer of listCtrl Header ctrl pointer using CListCtrl::GetHeaderCtrl( ); function
|
|
|
|
|
|
I've got an old C code header I'm porting to VC++ 2005. The code implementation looks something like:
#include <mmsystem.h>
...
void Initech::MyFunction()
{
midiInAddBuffer(...);
}
Compiling this, I get the following error:
error LNK2028: unresolved token (0A000016) "extern "C" unsigned int __stdcall midiInAddBuffer(struct HMIDIIN__ *,struct midihdr_tag *,unsigned int)" (?midiInAddBuffer@@$$J212YGIPAUHMIDIIN__@@PAUmidihdr_tag@@I@Z) referenced in function "void Initech::MyFunction()" (?MyFunction@@$$FYAIPAUmidihdr_tag@@@Z) Midi.obj
With C++ not being my native tongue, I'm kind of stumped at this error; what do I need to do to resolve it? Any help would be appreciated.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
you need to include winmm.lib into your build
|
|
|
|
|
|
try
#pragma comment(lib,_T("winmm.lib")) at the top of your cpp file where you calling Window multimedia related function
|
|
|
|
|
Thanks, I'll give that a try.
|
|
|
|
|
I've inherited an old vc++ 6 project, and loaded it into 2005.
Cleaning up the project, I tried removing a file called resource.hm, which contained the following line:
<br />
#define HIDC_TEST_LIST 0x80d43575 // IDD_TEST_DIALOG [Neutral]<br />
The IDD_TEST_DIALOG dialog does not exist in the project, nor are any of the resources defined as Neutral.
I also removed the following lines from the .rc file:
<br />
#define APSTUDIO_HIDDEN_SYMBOLS<br />
#include "resource.hm"<br />
#undef APSTUDIO_HIDDEN_SYMBOLS<br />
When I build, the lines are auto-generated in the resource script, and an empty resource.hm is created, causing a compile error.
From MSDN:
Your project's resource.hm file will only be created by the development environment when one or more dialog boxes have controls and when those controls have HelpID properties set to True in the Properties Window.
I scanned the .rc script for any references of HIDC_TEST_LIST, and none were found. I scanned for other HelpIDs, nothing. How in the heck do I get rid of this thing?
Montreal great Guy Lafleur, quoted by CBC on being mugged while vacationing recently in Buenos Aires: "I didn't have any time to react before I got a sucker-punch in the eye. It was like one of the players from the Bruins."
|
|
|
|
|
Delete and re-create the resource file, at least thats how I get it to work when loading problematic files into VC6.
|
|
|
|
|
Well I was able to recreate your problem. Then I was able to fix it too.
One or more of the controls in the dialog could be having help id s. Set this property(Help ID) to false. Each control in a dialog has got this property. Once you set this to false the lines that you mentioned
Jack Squirrel wrote: // Generated Help ID header file
#define APSTUDIO_HIDDEN_SYMBOLS
#include "resource.hm"
#undef APSTUDIO_HIDDEN_SYMBOLS
will not be regenerated. This should fix the errors that come up.
Help ids are located in resource.hm . Once you delete the above statement you are bound to get errors because the file is no more included and the symbols are undefined.
Nibu thomas
Software Developer
|
|
|
|
|
Nibu thomas wrote: One or more of the controls in the dialog could be having help ids.
Yep. I searched for HID* in the .rc file and didn't find anything. I thought it might be corrupted, since if a control was set to true, it's label should be appearing in the .hm file. I then went through each dialog (100+) in the resource editor, selecting all controls and ensuring the HelpID was false. One of the dialogs had it set to true for all controls, but all of the controls were unlabelled. (set to their ID numbers)
I created a new project, set the HelpID flag to true, and changed the ID to a number. (1001) Sure enough it failed to compile.
I tried changing the ID to TEST, and it wrote the help ID in the .hm as HTEST. I guess the HelpID writer doesn't like IDs starting with numbers - H1001 should be a valid label for a #define.
Montreal great Guy Lafleur, quoted by CBC on being mugged while vacationing recently in Buenos Aires: "I didn't have any time to react before I got a sucker-punch in the eye. It was like one of the players from the Bruins."
|
|
|
|
|
Hi ,
This is my first posting over here. Hope to have great answers here.
I have a (Dialogbox with a button) which I open from the Menu which is
vertical shaped and docked at the left side.
I click this button on the dialogbox and AfxMessagebox is flashed which
is at the center of the dialogbox . In that way its flashing at the
left side. I call a App's DisplayMessage function in order to show this
messagebox. I though if I display this dialog from App , it may come at
the center but that is not the case.
I want this AfxMessageBox to be flashed at the center of the frame.
I read few postings here. I used following code using SetWindowsHookEx.
Sombody before said to subclass the window of AfxMessageBox in the hook
procedure . I am not sure how to do it and after that how to reposition
the window at the center of the main framme/App. So I straightaway used
SetWindowPos but not working satisfactorily.
HHOOK hookSave;
LRESULT CALLBACK hookFunc(int nCode, WPARAM wParam, LPARAM lParam)
{
if ( HCBT_CREATEWND == nCode )
{
#define pcs (((LPCBT_CREATEWND) lParam)->lpcs)
HWND hwndSave = 0;
if( WC_DIALOG == pcs->lpszClass )
{
hwndSave = (HWND) wParam;
}
if ( hwndSave )
{
// subclass_dialog_any_which_way_you_want(hwndSave);
SetWindowPos(hwndSave,HWND_TOP, 10,50,500,300,SWP_SHOWWINDOW);
//MoveWindow(hwndSave,100,500,500,300,false);
//theApp.m_pMainWnd->SubclassWindow(hwndSave);
}
#undef pcs
}
return CallNextHookEx(hookSave, nCode, wParam, lParam);
}
void CLeeApp::DisplayMessage()
{
hookSave = SetWindowsHookEx(WH_CBT, hookFunc, NULL,
::GetCurrentThreadId());
AfxMessageBox("Just for check");
UnhookWindowsHookEx(hookSave);
}
I guess this related to making AfxMessageBox as a SubClassWindow to
MainFrame which should be subclassed in the hook function (Which I dont
know how to do in the hookfunction, means hot to get the main frame
handle) and then how to get the windproc of mainframe for afxmessagebox
and then hot to get all these things to work for Afxmessagebox to
center the mainframe
Could someone help me with some guiding code postings.
It will help me a lot.
Thank you,
Lee
|
|
|
|
|
Instead of using AfxMessageBox() , use the CWnd::MessageBox() method on the window you want the message box to be centred in, ie. If you want the message box centred on your main frame, call AfxGetMainWnd()->MessageBox(...) .
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks RYan ,
It helped
Just for learning purpose.
How to achieve it with AfxMessageBox using SetWindowsHookEx
and hook procedure?
How to subclass AfxMessageBox window to main window in the hook procedure and then how to to resize it. (please refer my code).
Thanks,
lee
|
|
|
|
|
yang__lee wrote: How to achieve it with AfxMessageBox using SetWindowsHookExand hook procedure?
I wouldn't ever do it that way, so I don't know how you'd do it.
yang__lee wrote: How to subclass AfxMessageBox window to main window in the hook procedure and then how to to resize it.
Message boxes are automatically sized? Why do you need a different size?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|