|
nrbracke wrote: Is it possible that this method is not allowing events to be processed by the window/form?
Yes it's possible.
You can, however, force the window to get an immediate WM_PAINT message by invalidating part
or all of the window (see InvalidateRect()/InvaliateRgn()) and calling UpdateWindow().
Also, check out RedrawWindow(), which combines the above mentioned operations.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If I Invalidate() the windows goes blank untill the method finishes its processing instead of updating with the components I have already added. What is preventing the paint method from getting called?
|
|
|
|
|
You need to call UpdateWindow() as well, so a WM_PAINT message gets sent to
the window. That window would need to actually draw in response to WM_PAINT.
You really should be doing lengthy operations on a separate thread if you want your
UI to stay responsive. By not letting the message loop run, you're preventing the UI
from getting and dispatching the messages it needs.
You could also periodically pump queued messages during your lengthy operation,
something like this:
<span style="color: Green;">
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!AfxGetApp()-> PumpMessage())
{
break;
}
}
<span style="color: Green;">
MSG msg;
while(::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
is there a way to add a popup menu to ClistBox control?
thanks
|
|
|
|
|
Gofur Halmurat wrote: s there a way to add a popup menu to ClistBox control?
One way would be derive a class from CListBox and add a WM_CONTEXTMENU handler
to the class. In that handler, use TrackPopupMenu() to show a popup menu.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I created a class which derived from CListBox, and I added WM_CONTEXTMENU handler, there is a problem, how can i use TrackPopupMenu()in the class?
I have the menus ID = IDR_MENU1, can i call it in the class? if so, how?
thanks
|
|
|
|
|
Gofur Halmurat wrote: I have the menus ID = IDR_MENU1, can i call it in the class? if so, how?
What did you try??
Take a look at TrackPopupMenu() in the PSDK or MSDN.
Here's one example:
CMenu popupmenu;
popupmenu.LoadMenu(IDR_MENU1);
...do some menu initialization if necessary...
int Command = (int)popupmenu.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, point.x, point.y, this);
...process the command... You can also use an appropriate window and catch the command message the normal MFC way.
You'd have to remove the TPM_RETURNCMD and TPM_NONOTIFY flags.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello Mark,
here is what i did in WM_CONTEXTMENU
<br />
popupmenu->LoadMenu(IDR_MENU1);<br />
int Command = (int)popupmenu->TrackPopupMenu(TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, point.x, <br />
point.y, this);<br />
when i click on the listbox, appears a bar(like 10x100), does not appear the menu, what do u think about why it doesnt show the menu?
thanks
|
|
|
|
|
Without seeing your menu resource, I have no idea.
Maybe try the first popup like I showed in my example...
...(int)popupmenu->GetSubMenu(0)->TrackPopupMenu(...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Also make sure you're tracking your menu resources....
You don't necessarily need to load the menu every time you get a WM_CONTEXTMENU
message - you can load it once, maybe in the constructor.
If you do choose to load it every time, make sure you release it
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
you are right, there should be GetSubMenu(0)-> , otherwise, it doesnt work,
It helped me alot
Thanks
|
|
|
|
|
Hello,
I have a question again, it shows the popup menu when i click rightbutton, but, how can we create popup menu message?
thanks
|
|
|
|
|
Hello,
Finally I understood that it should be like this
popupmenu->LoadMenu(IDR_POPUP); <br />
int Command = (int)popupmenu->GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, point.x, point.y, this);<br />
switch(Command)<br />
{<br />
case ID_POPUPMENU_EXIT:<br />
MessageBox("f***ing sh*t");<br />
break;<br />
}
thanks
|
|
|
|
|
Hehe...ah, the dreaded "f****ing sh*t" messagebox
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I want to sort array of data in ascending order associated with index.
for example
data 4 2 3 5
index 0 1 2 3
after sorting the result should be
data 2 3 4 5
index 1 2 0 3
can anybody help me with this problem
sarojsigdel
|
|
|
|
|
This code does not answer your question exactly but it should give an idea on how to do it:
#include <iostream>
#include <vector>
#include <algorithm>
using std::wcout;
using std::endl;
using std::vector;
using std::sort;
typedef vector<int*> pint_v;
typedef pint_v::iterator pint_i;
class SortPtr
{
public:
bool operator()(const int* v1, const int* v2)
{
return *v1 < *v2;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
int values[] =
{ 10, 9, 8, 7, 6, 5, 5, 4, 3, 2, 1 };
size_t count = sizeof(values)/sizeof(values[0]);
pint_v values_v;
for (size_t i = 0; i < count; ++i)
{
values_v.push_back(values + i);
}
SortPtr sp;
pint_i begin = values_v.begin();
pint_i end = values_v.end();
sort(begin, end, sp);
for (pint_i i = begin; i != end; ++i)
{
wcout << values[*i - values] << endl;
}
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hmm, I get a 1 rating for my answer that actually sorted the array by its index (well, it was actually using pointer arithmetic. *i + values evaluated to the array index.) without a reason why!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
i think it's because you shouldn't do someone's homework, at least, not entierely. Moreover, you don't even use any of the formating html tags, so your message looks a little ugly...
by the way, it's just my feeling, i don't know the voter's reason though
|
|
|
|
|
I appreciate your comments and I have learned something from them. I have been beaten up physically (survived a t-bone auto accident) and mentally (depressed about becoming a senior). Sometimes, I question why I should even attempt to post replies here.
Thanks,
Geo
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
George L. Jackson wrote: Sometimes, I question why I should even attempt to post replies here
i wonder the same sometimes. but if you know your presence here is worth it, then don't care about the low rates, there will always some other ones to pull your messages up.
keep it up George. i've seen you to be a good member of the Managed C++ forum.
but try to follow the posting guidelines, especially when you post code samples (the <pre></pre> tag is dedicated for that). also, always think about the interrest of the OP. if a student is asking for a code, even though you can write it in a flashlight, would you do it, or try to convince him to listen at his teacher and try himself to do his homework ? one will never learn anything if no effort is supplied...
|
|
|
|
|
I get down on myself at times but I usually snap out of it! Any way, Rodney Dangerfield made a career on "no respect".
I did break the tutoring ethics by supplying code rather than supplying informative suggestions. For that, I slap my own hand. Ouch!
I will make an attempt to create beautiful example code. For, if it looks ugly, it may run ugly.
Thus, on this day of becoming a senior, I will bring forth an effort to be a better poster. I feel rejuvenated already!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
This one is even better. This will work with more types.
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using std::wcout;
using std::endl;
using std::vector;
using std::sort;
using std::less;
template <typename It, typename Pred>
class dereference_predicate : public std::binary_function<It, It, bool>
{
public:
dereference_predicate() {}
dereference_predicate(const Pred &pred) : pred(pred) {}
bool operator()(const It &a, const It &b) const
{
return pred(*a, *b);
}
private:
Pred pred;
};
typedef dereference_predicate<int*, less<int>> pint_less;
typedef vector<int*> pint_vctr;
typedef pint_vctr::iterator pint_iter;
int _tmain(int argc, _TCHAR* argv[])
{
int values[] =
{ 4, 2, 3, 5 };
size_t count = sizeof(values)/sizeof(values[0]);
pint_vctr values_vctr;
for (size_t i = 0; i < count; ++i)
{
values_vctr.push_back(values + i);
}
pint_iter begin = values_vctr.begin();
pint_iter end = values_vctr.end();
less<int> less_than;
pint_less dp(less_than);
sort(begin, end, dp);
for (pint_iter i = begin; i != end; ++i)
{
size_t index = *i - values;
wcout
<< L"values["
<< index
<< L"] = "
<< values[index]
<< endl;
}
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
if i have understood your problem correctly, then here is the solution.
while sorting the first array, perform the swapping of the elements in the second array also.
means, the items in hte second array need not be sorted right?
but there will always be one to one mapping among both the arrays.
if my post didnot answer you,
then please explain your task a bit clearer.
|
|
|
|
|
I have two .NET 2.0 components:
Component A was purchased from a third-party with a license that they generated based on SNK file that we provided.
Component B we implemented that tries to use component A. It is signed with the same SNK file, and also exposes its interface via COM interoperability.
Now, if I try to use component B from a .NET application, then the license verification for component A fails until I sign my .NET application with the same SNK file, and then it’s fine.
The problem is that the same logic doesn’t work if I try to use component B from a C++ application via COM. My C++ application is unmanaged, written under VS2005SP1. In the project settings I tried to put my SNK file into Configuration Properties->Linker->Advanced->Key File, but to no avail. The way I see it, this option is only applicable to assemblies, which my C++ doesn’t even have.
Question: How do I sign my C++ application with the given SNK file in my case, so that license of component A works just as it does in my .NET application?
Free C++ libraries with source code on www.neatcpp.com: TWAIN, DirectShow, Interprocess Communications, etc...
|
|
|
|
|
Can anyone please let me know the way by which i can implement a custom PrintScreen program for capturing a movie scene ?
Print screen button doesnot capture the movie window contents.
|
|
|
|
|