|
I have made deskband object. How to programmatically show and hide it?
If that was explorer bar, i'd use IWebBrowser2::ShowBrowserBar.
Thank you!
|
|
|
|
|
Did you ever get an answer?
|
|
|
|
|
Just for learning purposes, I'm trying to implement the code Mark Petrik Sosa put in a message at 6:47 14 Apr '05 in a reply to 'Send Messages to Other Windows' (4:34 14 Apr '05).
<br />
HWND hNotepad = FindWindowEx(0, 0, "Notepad", 0);<br />
if(hNotepad)<br />
SendMessage(hNotepad, WM_SETTEXT, 0, (LPARAM) "Hah, I found you!");<br />
else<br />
MessageBox(0, "Couldn't find notepad.", "Darn", MB_OK);<br />
<br />
When I compile, I get:<br />
error C2440: 'initializing' : cannot convert from 'CWnd*' to 'HWND'<br />
error C2660: 'CWnd::SendMessageA': function does not take 4 arguments<br />
<br />
If I change to <br />
CWnd* hNotepad = ...<br />
and then<br />
SendMessage(hNotePad->m_hWnd, ...<br />
I still get the C2660 error.<br />
<br />
I also get<br />
'CWnd::MessageBoxA': function does not take 4 arguments<br />
I can see that SendMessage has 2 prototypes - one takes 3 arguments and looks like it's for the cases where you do not need to specify a handle.
Would appreciate any direction on how to fix the code and/or explanations to help me understand the mechanisms involved here.
|
|
|
|
|
::SendMessage(hNotepad, WM_SETTEXT, 0, (LPARAM) "Hah, I found you!");
and
::MessageBox(0, "Couldn't find notepad.", "Darn", MB_OK); or MessageBox("Couldn't find notepad.", "Darn", MB_OK);
|
|
|
|
|
Thanks.
It now compiles and executes properly.
If you have another minute though, I still get the error 'initializing': cannot convert from CWnd* to HWND unless I declare hNotepad as CWnd*. Then when I do that I have to use hNotepad->m_hWnd, which makes sense. Is there some include file I need such that I can declare hNotepad as HWND and then use it as you and Mark used it (i.e., without the ->m_hWnd)?
|
|
|
|
|
If you dereference your pointer ( *hNotepad ), then operator HWND should come to the rescue.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I haven't found the secret yet. If I still declare with CWnd
<br />
CWnd* hNotepad = FindWindowEx(...<br />
then I can use
<br />
::SendMessage(*hNotePad, ...<br />
But if I declare with
<br />
HWND hNotepad = FindWindowEx(...<br />
or
<br />
HWND *hNotepad = FindWindowEx(...<br />
I still get the error message
'initializing' cannot convert from CWnd to HWND
Is it maybe because the 2003 compiler is more strict than compilers in the past? I don't have much experience/history with Visual C++.
|
|
|
|
|
Has anyone ever tried (and managed) passing the IP number of the remote machine instead of the machine name in the remote filename url?
I can successfully create a BITS job when i specify the remote file using the machine name in the url, but somehow the job cannot be created when i specify the ip number of the same machine in the url instead of the name. Any ideas anyone?
(If it can help, the remote machine ip is dhcp-assigned, but i don't think this can create a conflict)
|
|
|
|
|
Hi,
How can I get the DWORD or Binary Value using RegQueryValueEx function?
Cheers,
Thanks.
|
|
|
|
|
<code>DWORD dKeyValue;
DWORD dType;
DWORD dSize=sizeof(DWORD);
RegQueryValueEx( hKey, "KeyName", NULL, &dType,
reinterpret_cast<LPBYTE>(&dKeyValue), &dSize)</code>
suhredayan
|
|
|
|
|
Hi guys
I'm working in an app that starts to be big and I have a little-big problem.
When I touch an .h file the VC++ 6.0 recompiles practically the complete app.
Why do you think this is due to?
There is some Setting to change?
Is due to includes?
Some clue?
Have you experimented this too?
Thanks in forwarding
Doc
|
|
|
|
|
Visual C++ will recompile any file that it decides is dependent on that file. If you edit a commonly-used header, it will recompile most of the application.
To resolve this, first remove any unnecessary includes from source files - only include those headers actually required. If you're using a precompiled header file (a default VC project uses StdAfx.h as the header file for generating precompiled headers) you should only include in that header headers that are very stable.
In some cases you may have used #include in a header file where the actual definition is not required - i.e. the class declared in the header is only passed or stored as a pointer or as a reference. If this is the case you can remove the #include and only give a forward declaration, e.g.
#include "MyClass.h"
class MyOtherClass
{
public:
MyOtherClass( MyClass* pMyClass );
private:
MyClass* m_pMyClass;
};
class MyClass;
class MyOtherClass
{
public:
MyOtherClass( MyClass* pMyClass );
private:
MyClass* m_pMyClass;
}; If this is still causing too much to be regenerated, you can use a trick called, variously, a compilation firewall, the Cheshire Cat technique, or the Pimpl Idiom[^]. Pimpl stands for Pointer-to-implementation.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks guy
I'll take a look about this.
The point then is replace includes by class where possible?
Doc
|
|
|
|
|
doctorpi wrote:
The point then is replace includes by class where possible?
Yes. Here are some hints of what is possible:
<code><font size=2 face="Courier New"><font color="#000080">#include "notpossible.h";
class</font><font color="#008080"> </font>Possible;
<font color="#000080">class</font><font color="#008080"> </font>MyClass
{
<font color="#000080">public</font>:
<font color="#008080"> </font>Possible<font color="#008080"> </font>foo<font color="#008080"> </font>(Possible<font color="#008080"> </font>v,<font color="#008080"> </font><font color="#000080">const</font><font color="#008080"> </font>Possible&<font color="#008080"> </font>r,<font color="#008080"> </font>Possible*<font color="#008080"> </font>p);
<font color="#008080"> </font><font color="#000080">void</font><font color="#008080"> </font>bar()
<font color="#008080"> </font>{
<font color="#008080"> </font>NotPossible<font color="#008080"> </font>n<font color="#008080"> </font>=<font color="#008080"> </font><font color="#000080">3</font>;
<font color="#008080"> </font>}
<font color="#000080">private</font>:
<font color="#008080"> </font>NotPossible<font color="#008080"> </font>nope;
};
</font>
</code>
|
|
|
|
|
Hi
I have already posted this kind of question before this one but didn't get any answer which satisfies me, so again posting it.
I have developed a multithreaded application ( a windows service ), which runs on Windows 2000 Professional.
I have made it using VC++.
My problem is : I want to create 10,000 threads and what to keep all threads running without suspending at all the times. So is there any other way to create such big number of threads and is it feasible to create such a greate many number of threads ? What will be resourece utilization if i create such threads....I think my CPU memory will be used 100% and it will get hanged....is it ?
Any suggestion, any help....plz
Thankx in advance
Regards,
Amarelia Mahesh
Gujarat
India
|
|
|
|
|
You can't do it. Find some other way.
Technical details: threads by default have a 1MB user-mode stack reserve - 1MB of the process's address space is reserved for the thread's stack. They also have a few pages of kernel stack reserved.
A simple bit of arithmetic reveals that if you tried to create 10,000 threads you would need 10GB of address space for user-mode stacks. You only have 2GB of user-mode address space available. Therefore you can't do it.
Large numbers of threads also slow down the system's scheduler code, and increase the amount of memory used for book-keeping. If all the threads are runnable, not blocked waiting for a resource, they will get in each others' way - the system is likely to spend more time in the scheduler than acttually doing useful work.
If you're trying to handle concurrent requests by using one thread per client, switch to a pool of threads.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
|
Amarelia wrote:
...but didn't get any answer which satisfies me...
So even though the answers you received in your other post eluded to the fact that 10000 threads is not possible, or even smart, you are not satisifed. Why?
It should be a simple matter of creating a thread pool having a few dozen threads to monitor any number of mailboxes you may have.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Don't be lazy - write your own scheduling functions, within a single threaded application, with this number. You are expecting the O/S to do a job that you will have to be doing.
|
|
|
|
|
It is helpful to at least understand some basic concepts of multi-threading before you actually attempt it.
1) The vast majority of machines have one CPU. One CPU = one active thread at any given time, period.
2) One CPU = one thread, period. Windows does not run threads concurrently. It switches between threads to give the appearance that tasks are running concurrently.
3) Multi-threading does not speed anything up - it slows it down because of the additional overhead of thread switching.
4) Since multi-threading slows an application down, it is generally useful only in cases where you want to keep an application responsive while running some slow background task. A good example is where you want to print something on a background thread.
5) There are only a few types of applications that really require the use of multiple threads. Almost all of these fall in the realm of "real time applications" or debuggers. For example, an IVR telephone system generally requires multiple threads so that a call that comes in on the 4th channel does not wait on the three channels that are already active to try to answer the call.
As a general rule of thumb, if your application is not a debugger and does not involve supporting special hardware, like a telephone card, multi-threading is probably not a good idea in general unless you really know what you are doing.
6) 10,000 threads? LOL! The concept is absurd!!! If an application creates 10 threads it is cause to question why so many? Try sticking to 5 or less unless some special requirements dictate more.
Robert
|
|
|
|
|
Is there a preferred way to insert items in a tree, non leaf items, that follow a predefined ordering ( not using TVI_SORT ) ?
I have to insert those items on the fly, so that when an item is inserted, they can be inserted between to other existing items.
I have to insert the items "Tomato", "Potato", "Leaks", "Avocado", "Celery" in that order.
If I insert "Leaks", it's a no brainer, but if I insert "Potato" after that, I need to manually check to see if "Tomato" is already inserted to be able to put that item as the hInsertAfter field ( or TVI_FIRST ); and so on and so forth for the other items ...
Luckilly, I have a small set of items to check.
Is there a better way ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
That's exactly how I do it when I'm inserting a new item. However when I'm loading up the whole tree, I can usually sort the strings better myself using for loops and then once I know they are in order, I can add them with TVI_LAST.
|
|
|
|
|
Is it possible to assign the "image value" of a CImage object to a Bitmap object?
I have to use CBitmap class but i have to load a jpg file.
Like this code:
---------------------------------------------
CImage CImg;
CImg.Load("c:\\background.jpg");
CBitmap bitmap;
// bitmap = CImg; !?? How can I do?
-------------------------------------
Thanx
|
|
|
|
|
Perhaps something like this is what your looking for. Just drawing the CImage to a CBitmap.
CImage image;
CBitmap bitmap;
int width = image.GetWidth();
int height = image.GetHeight();
CDC window_dc(m_hWnd);
CDC dc;
dc.CreateCompatibleDC(window_dc);
bitmap.CreateCompatibleBitmap(dc, width, height);
dc.SelectObject(bitmap);
image.Draw(&dc, CRect(0, 0, width, height));
|
|
|
|
|
How to create and read a file where the exe is residing?
How to open a file using ShellExec() from the current directory so that i can avoid problems that may arise when porting to other system as i can't expect the same drive name etc in other systems also;)
|
|
|
|