|
Stanislav wrote:
int ret=dlg.DoModal(this);
How did you compile that?
CDialog's DoModal is defined as :-
virtual int DoModal();
But you can do this :-
GetParent()->GetActiveView()->YourFunction() from your modal dialog.
Casting might be required.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hello, the codegurus around the world;)
There are many ways to get CWnd of view and doc.
1) Pass CWnd of CBanView of the constructor of your dialog.
2) GetParent() may work.
3) Get the frame's CWnd by AfxGetMainWnd() and use GetActiveView() of
CFrameWnd.
4) Create the static function like GetView().
(You can find this static function in somewhere of MSDN.)
CFrameWnd has GetAcitveDocument() or use inline GetDocuemt() in View class.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
10x, both, i
managed to do it with
the static CMyDoc *MyDoc(); which
was described in a article in MSDN-a
|
|
|
|
|
I've got this ActiveX Object (made w/ VC++6.0), it creates a thread (so i can have multiple running at the same time), but it also fires events to my Visual Basic App. With me creating threads cause problems for those events trying to get back to the application?
It seems that way. VB seems to crash when i Fire an event. When i use an activex control, does it have its own thread? Can i redirect the thread ID or something like that? It's just being flat out weird. Has anyone had the same trouble before? I set up connection points at the beginning when i made the obj., is there any other settings that i need to have? Even a little bit of help will go a long way for me...Thanks Y'all.
~TIM!
SHABBA!!
|
|
|
|
|
template< typename T >
__forceinline T EPS( )
{
return 0;
}
template< >
__forceinline double EPS< double >( )
{
return DBL_EPSILON;
}
template< >
__forceinline double EPS< float >( )
{
return FLT_EPSILON;
}
template< typename T >
bool IsWorking( const T& r, T dEpsilon = EPS<t>( ) )
{
return true;
}
Is this is a valid C++ ?
I got "fatal error C1001: INTERNAL COMPILER ERROR" on MSVC
|
|
|
|
|
No, you can't make a template function where the only occurence of the template param is the return type. This is a limitation of MSVC. Change it to:
template<typename T> __forceinline T EPS( T* = NULL )
{
return 0;
} and change the other specializations accordingly to work around this limitation.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (1
|
|
|
|
|
No, this is not valid C++. It uses non C++ keywords.
I'd also add that MSVC is woefully inadequate when it comes to template handling. It can't handle more than the most basic use of templates. Function template specialization and partial template specialization it's especially bad at. Actually, function templates hardly work at all after sp3 (unless you're only instantiating one just one type/T.U.).
|
|
|
|
|
Is there a way to custom draw the slider control? I would like to change the color or even better, attach a bitmap to the control.. Anyone have any samples of code or know where I should start?
Thanks,
Rob
|
|
|
|
|
One way would be to subclass it and write your own OnPaint function. OnEraseBkgnd may help with a background image.
These are only ideas and I have not tested them, but that is where I would start.
Happy programming!!
|
|
|
|
|
Thanks.. I just found some articles on MSDN on how to custom draw a slider(track bar).. I'll do some looking into your idea and look at MSDN.. I have a bitmap in the back ground of my dialog so I like your idea of sub classing the sliders and erasing the background.. then I really wouldn't need to "skin" the slider (maybe just the knob).. Anyway, thanks for the reply!!
Rob
|
|
|
|
|
Sliders send NM_CUSTOMDRAW to their parent, like other common controls. With sliders you can custom-draw the thumb, the channel, and the tick marks. If you need a background to show through, subclass the slider and handle WM_ERASEBKGND.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (1
|
|
|
|
|
Hi
is there a way to avoid flickering in a list control if many items are inserted into the list control e.g. by a loop?
thanks in advance
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Send a WM_SETREDRAW message, wParam=FALSE before your loop. After you're done, send it again with wParam=TRUE, then call InvalidateRect() to have the control redraw.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (1
|
|
|
|
|
Hi all, I`ve written some convolution code and managed to get the filters and stuff going fine, the only trouble is the speed! If I so much as use a vector once in the final nested for loop (where it works out the position of the filter with regards to the image) it slows the process down considerably (and I mean considerably - instead of being instant, theres at least a couple of seconds delay). In my code I *need* to access this memory bank at least three times in the final nested for loop (once for Red, Green Blue). Delphi has dynamic arrays which do the job perfectly, I was just wondering what the best way was in VC++? I`ve thought of using pointers, performing a small sum and accessing the pointer at that position, however I`d prefer to use the [] operator as it makes my code that little bit easier to read. Any ideas on better methods for quick access to retrieving data in memory, or as to why my bloody vectors are so slow (I'm using multidimensional vectors, 2-d ones, the location of which is stored in a vector, so I`m actually using a vector of a vector of a vector, but I didn`t think this should slow it down to the amount it is doing? Also my images are quite small, if used a large image I could probably make myself a cup of tea and drink it before it finished!!!) would be much appreciated. Thanks anyway guys,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
If your vector exists prior to the loop ( i.e. is not created or modified in terms of size inside the loop ), then I don't see why this would happen. A vector IS a pointer ( a block of continuous memory accessed using pointer offsets ), so you wouldn't get any speed doing it the pointer way, I would think. Having said that, I have always used pointer logic to step through bitmaps myself, and don't consider it hard to read. In other words, I do not speak from experience as I've only done it the alternative way you're proposing in the first place
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Depending on what you have in your vector it's quite possible you are copying the data out of the vector instead of accessing it. Can you describe what you are stroing in your vector and how you're accessing it?
Todd Smith
|
|
|
|
|
Yeah I`m only storing integers in the vectors, and as Christian said I can`t understand why the vectors are so slow. However, I`ve since adopted a pointer to an int system, and used a small calculation to work out the position of the relevant integer in the list that is to be used in the convolution stuff. Result - it was sh**loads faster. Just by changing from vectors to pointers made an absolutely massive difference (it was literally the difference between almost instansteously performing the convolution, and waiting a good few seconds for the *exact* same code to run through). I think it must just be because I`m accessing my vectors like so:
...
for (int i=0; i<3; i++)
for (int j=0; j<3; j++)
{
*blue = blue + *(pBits+0) * myVector[a][b];
*green = green + *(pBits+1) * myVector[a][b];
*red = red + *(pBits+2) * myVector[a][b];
}
...
Instead of using myVector, I use pointers to an int (pInt - for arguments sake, and cos I like pInts of strongbow!), as follows : *(pInt+(a*width+b));
And the result is that its loads faster. Hope someone can shed some light on why this is the case, although it doesn`t matter to me now, I`d still like to know why? Thanks guys,
Cheers,
Alan.
P.S. Christian, I think to me, you and the others who are improving their C++ vocabulary every day, reading pointer code is a *relatively* simple task. However, the reason I mentioned this before is that some of my MSc markers are real programming bone heads (the're mathematicians), so I was just thinking that such people might find it *easier* to read and *understand* the vector code, what do you reckon? I`m gonna go with the pointer stuff anyway, it just means extra explanation in the final write up. Cheers though for your advice I do appreciate it.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
I think Tim nailed it when he mentioned copying data out of the vector.
when you do a plain C array with fixed indexes like this, the compiler can generates code that references that value directly (or as an offset from the array base) - ie. it really is equivalent to value = *(arrayBase + offset) . but, with a vector, you're doing something like:
find the data
make a copy of the data
return the data
-c
Smaller Animals Software, Inc.
|
|
|
|
|
Here's the evilness of vector
notice that the [] operator calls begin
reference operator[](size_type _P) {return (*(begin() + _P)); }
and begin CONSTRUCTS! an iterator. That blows.
iterator begin() {return (iterator(0, _Vec.begin())); }
Todd Smith
|
|
|
|
|
This is scary. Here's my test program
int data[10];
int sum = 0;
for (int i = 0; i < 10; i++)
{
sum += data[i];
}
std::vector<int> vdata(10);
for (int j = 0; j < 10; j++)
{
sum += vdata[i];
}
and here's what the difference between the two assembler dumps
sum = data[i] becomes
mov ecx,dword ptr [ebp-3Ch]
mov edx,dword ptr [ebp-38h]
add edx,dword ptr [ebp+ecx*4-34h]
mov dword ptr [ebp-38h],edx
and the vector method sum += vdata[i] becomes
mov eax,dword ptr [ebp-3Ch]
push eax
lea ecx,[ebp-4Ch]
call @ILT+525(std::vector<int,std::allocator<int> >::operator[]) (00401212)
mov ecx,dword ptr [ebp-38h]
add ecx,dword ptr [eax]
mov dword ptr [ebp-38h],ecx
"@ILT+525(std::vector<int,std::allocator<int> >::operator[]) (00401212)"
push ebp
mov ebp,esp
sub esp,44h
push ebx
push esi
push edi
push ecx
lea edi,[ebp-44h]
mov ecx,11h
mov eax,0CCCCCCCCh
rep stos dword ptr [edi]
pop ecx
mov dword ptr [ebp-4],ecx
mov ecx,dword ptr [ebp-4]
call @ILT+475(std::vector<int,std::allocator<int> >::begin) (004011e0)
mov ecx,dword ptr [ebp+8]
lea eax,[eax+ecx*4]
pop edi
pop esi
pop ebx
add esp,44h
cmp ebp,esp
call __chkesp (0040e8b0)
mov esp,ebp
pop ebp
ret 4
"@ILT+475(std::vector<int,std::allocator<int> >::begin) (004011e0)"
push ebp
mov ebp,esp
sub esp,44h
push ebx
push esi
push edi
push ecx
lea edi,[ebp-44h]
mov ecx,11h
mov eax,0CCCCCCCCh
rep stos dword ptr [edi]
pop ecx
mov dword ptr [ebp-4],ecx
mov eax,dword ptr [ebp-4]
mov eax,dword ptr [eax+4]
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret
I think I know where the 2 seconds went
Todd Smith
|
|
|
|
|
Thankyou guys, I can now finally put my mind at rest! There was me thinking my new Pentium 4 machines were bunk, when all along it was those bloody vectors! Interesting note you made with regards to the difference between an array of 10 integers and a vector of 10 Todd, even I was suprised by the excessive routine it goes through, geeze. Well, I must say cheers to all you guys for coming up with the solution, at least we all know not to use vectors in a similar situation again, AND we know why.
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
I've cross posted this into the C++ forum, cause a) it didn't get answered in the COM forum, b) the most knowledgeable people seem to hang out here. This problem was presented to me by a co-worker. It really has me stumped.
In our shop we utilize an application generator "Cool Plex". It builds C++ code and compiles it into dlls. One of its abilities is to include ActiveX controls on a screen. We have written an ActiveX control that dynamically creates a form using Combo box, ListBox and Ms MaskEdBox control. A typical usage might include 2 or 3 instances of each.
The Problem:
Inside our ActiveX we capture the Tab key in each control (control_OnKeyUp) and set focus to the next control, except for the MaskedEdit controls. We get other keys in the KeyUp event, but not the Tab key!!??
If I create a VB app and embed the control in it, the tabbing works as normal, So far, even worse. Now it appears the PLEX generated application is inhibiting the Tab key from getting to the MaskedEdit control which is encapsulated in our ActiveX control. Other encapsulated controls seem to work fine.
It seems to me that these symptoms are mutually exclusive. I don't see how this is possible, but the developer on this project has convinced me that this is what is happening.
1. PLEX container passes (or never gets) Tab key presses to the ActiveX control.
2. PLEX container inhibits the Tab key when the focus inside the ActiveX control is in a MaskedEdit control.
3. I believe the encapsulated control with the focus, gets the events before PLEX, precluding inhibiting the tab key at all.
4. PLEX container has no way to differentiate the encapsulated control with the focus from any other.
5. PLEX container has no way to differentiate the type of control. How could it know that the focus in our Activex control is on a MaskEdBox?
Thanks for the help,
Bill
Thanks for the help,
Bill
|
|
|
|
|
I'm making a dictionary application and I want to know how to map message, when users key-in their vocabulary in combobox and then press enter, with my "Search" procedure. I already mapped button message with my "Search" procedure. I don't know how to use WM_KEYDOWN or ON_WM_KEYDOWN.
Help me, please..
|
|
|
|
|
Hi!!!
Kindly suggest me a resource/web site from where I can get the sample documentation reports of Software projects. I just want to get the idea that how modern professional software documents are been written these days, and how various phases of SDLC are managed.
Sheeraz Khan
|
|
|
|
|
|