|
Hi All,
I was trying with Michael Dunn's article on Introduction to COM
I had a try with my own console application. But in the beginning itself, it said that IActiveDesktop is undeclared. I included shlobj.h but no use at all.
But the sample he provided working fine in VC++ 7.0 but mine is not working well
could you please help me in this regard?
|
|
|
|
|
Did you see StdAfx.h in example form Mr Michael Dunn's if you see you can solve your problem
|
|
|
|
|
I created an application which is using precompiled header.
Even I copied his code to a new project file with same name, it's not working.
I think i have to do something wtih project settings.. can't find what it is
|
|
|
|
|
I dont understand why you cant find your problem its not hard I see this article and see stdafx.h I suggest you check all include files in this article I hope you find your problem
|
|
|
|
|
Look in the header files. I've had a look and it seems that:
- WIN32_IE needs to be defined >= 0x400.
- _WININET_ needs to be defined.
You get _WININET_ defined by #include ing <WinInet.h> before you #include <ShlObj.h> . You typically define WIN32_IE in your "stdafx.h" with code something like the following:
#define _WIN32_IE 0x0400
Do this before you include any files.
Steve
|
|
|
|
|
Can I pass a parameter to the function if I have a worker thread and use AfxBeginThread?
|
|
|
|
|
From MSDN[^]:
CWinThread* AfxBeginThread(
AFX_THREADPROC pfnThreadProc,
LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,
UINT nStackSize = 0,
DWORD dwCreateFlags = 0,
LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL
);
pParam<br />
Parameter to be passed to the controlling function as shown in the parameter to the function declaration in pfnThreadProc.
|
|
|
|
|
I've also read that but I still don't understand??!!?
|
|
|
|
|
Then ask a clear question. What is your problem ?? We cannot guess it.
Why don't you just pass your data (as a pointer for example) using this parameter ?
|
|
|
|
|
This is my controling function
UINT CMina_sView::run(LPVOID p)<br />
{<br />
<br />
CMina_sView * me = (CMina_sView *)p;<br />
me->ascultarea();<br />
return 0;<br />
<br />
}
And this is how I start the thread
void CMina_sView::OnList() <br />
{ <br />
running = TRUE;<br />
AfxBeginThread(run, this);<br />
}
I want to pass a paramater to ascultarea. How do i do it?
|
|
|
|
|
You already passed a parameter to your thread: it's the address of the class (the this parameter). So, you cannot pass two parameters.
But, why do you want to pass a parameter to this function ? Why don't you just have a member variable that hold this variable so that the function ascultarea can use it ?
|
|
|
|
|
The OnList is a menu item that opens a dialog in which I can select smth a i hold that in dlg.m_sel. I want to be able to pass dlg.m_sel to ascultarea.
|
|
|
|
|
tanarnelinistit wrote: I can select smth a i hold that in dlg.m_sel
Please make a little effort on the spelling because I cannot understand (english is not my mother tongue).
When are you opening the dialog ? Before or after spawning the thread ? If it is after, then why don't you simply take this value (dlg.m_sel) and store it into a member variable of CMina_sView ? Then in your thread, as you call the function ascultarea, as it is inside the SAME class, you don't need to pass it to the function. The function can simply get it from the member variable.
I think the problem is that you don't know what you are doing. You probably found some snippet of code to start the thread but you don't understand the mechanics beyond that. Am I right ? Then, I cannot explain you in details because the subject is fairly too large. (And I already provided you with the solution).
|
|
|
|
|
1)I knew I should've studied french a little more in highschool.
2)I started programing in VC++ just one month ago but I've read and understood anything I could in one month.
3) I open the dialog and then I spawn the thread.
|
|
|
|
|
I already explained you the solution 2 times. Once more won't help you to understand it better. After one month of studying C++, it is not a good idea to jump directly to thread manipulation (even more if you didn't know a programming language before).
The only advice I can give you is: start slowly. Try to find a good book or course and start to learn the basics first. Otherwise, you'll screw up everything and you'll be really disgusted for life.
|
|
|
|
|
Ok. Thanks a lot. Although I feel a little bit disapointed now, I got your point.
|
|
|
|
|
See Here[^] maybe it is some helpful to you
|
|
|
|
|
Hi,
I hav a class which derived from the CFileDialog.
I gave OFN_ALLOWMULTISELECT option for that.
I want to update the CfileDialog when I change the file extension. So I override the function OnTypeChange() in that ...
I don't know what is the next..?
How can I update the files displayed on the CFileDialog window, when i change the extension( file type ) ????
I just tried it...!
CFileDialog is not updating that...!
CString szFilter = "AVI Files (*.AVI)|*.AVI|Bitmap Files (*.bmp)|*.bmp|All Files (*.*)|*.*||";<br />
CFileDialog FileSelect( TRUE, NULL, NULL, OFN_ALLOWMULTISELECT, szFilter, this );
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
if there is allocation of some memory in console application and then it quits without deallocation (that is mem leak). Will windows free this leak itself after console application is terminated?
9ine
|
|
|
|
|
yes, but you should really fix the mem leak first
Darka [ Xanya]
"When you're taught to love everyone, to love your enemies, then what value does that place on love?"
|
|
|
|
|
it is supposed to, but it might fail sometimes in tracking such memory... so, good programming practices remain the best : you allocate some memory ; then, YOU delete it before exiting the program.
|
|
|
|
|
yeah, I know, I know. But this should be some kind of advantige for console app if do a lot mem allocation, files handles, then you can allow yourself to get rid of that collection of all those resources and garbagging your code.
Its not the case when you write some class to be perfect without any leaks or handles.
9ine
|
|
|
|
|
why because it is a console application that it couldn't be OOP ?
and what is that way of thinking that console applications should be less well designed than graphical apps...
really, i don't understand your point of view.
|
|
|
|
|
Whats the point, writing additional mem free routines to get rid of allocated ones, as it will be deallocated after console is terminated. It is very well designed and quite large but without deallocation.
How can it be OOP one?
9ine
|
|
|
|
|
9ine wrote: Whats the point, writing additional mem free routines to get rid of allocated ones, as it will be deallocated after console is terminated. It is very well designed and quite large but without deallocation.
This makes no sense. Technically, heap memory will be reclaimed by the OS after the program terminates, but if you fail to free it yourself when you are done with it, then your program will slowly (or not so slowly) eat up more and more memory while it is executing (assuming you are allocating based on some set of events -- and if you are not, chances are that data would be better served on the stack anyway). As far as file handles (and pretty much any kernel object), they will NOT be reclaimed when your program exits. This means that if you open a file and then quit, you may need to restart your computer before you can reopen that file (NOT GOOD!).
The point is, if you allocate memory, you should free it. If you don't, do not submit that code as an assignment nor as production code for any company ... it will be rejected as incomplete.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|