|
Nice! Thanks.
I implemented your code. However, Window would not paint the bitmap onto the button. Maybe I did something wrong.
Kuphryn
|
|
|
|
|
Okay. I made a mistake and did not set the button to process accept bitmap.
Thanks again.
Kuphryn
|
|
|
|
|
Hi,
I use pDC->ExcludeClipRect(rectItems) to exclude a part of the client area being painted. This should be temporary and I like to add the rectangle again (restore previous clipping region)....
...but there is no CDC::IncludeClipRect() ?
Prolly I should work with help of SaveDC/RestoreDC instead, what do you think?
Thanks for help
Moak
|
|
|
|
|
Use CDC::ExtSelectClipRgn, this will add the new rgn that you specify to the existing clipping region. You may also want to check out a tutorial that I wrote on ^].
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Okie thanks, I'll have a look on it!
|
|
|
|
|
Hey, I'm a beginner at programming. I just read a tutorial on Combo Boxes and I now want to use the string of the selected option in a different function. How can I do this?
Heres the code for the combo box function.
void CAlertmakerDlg::OnSelchangeFont()
{<br />
UpdateData(); <br />
<br />
if( m_fontnumber < 0 ) return;
<br />
CString str;<br />
m_fontlist.GetLBText( m_fontnumber, str );<br />
}<br />
|
|
|
|
|
Never mind, I found out.
Instead of using:
<br />
CString str;<br />
m_fontlist.GetLBText( m_fontnumber, str );<br />
I should have been using:
<br />
m_fontlist.GetLBText( m_fontnumber, m_fontname );<br />
m_fontname is defined earlier in the program.
|
|
|
|
|
I have a program that calculates an exponent recursively. It's time complextity is O(n lg n). I would like to know whether anybody knows how I can improve my program to make it into a O(lg n) program. Please help!!!
here is my code:
#include <iostream.h><br />
#include <math.h><br />
#include <ctime><br />
<br />
void PersonalDisplay(void);<br />
int powerNOTRECURSIVE(int x, unsigned n);<br />
int powerRECURSIVE(int n, int k);<br />
<br />
void main(void){<br />
<br />
<br />
long ans=0;<br />
long base=0;<br />
long exponent=0;<br />
<br />
clock_t startclock = 0;<br />
clock_t endclock = 0;<br />
<br />
<br />
<br />
cout<<endl;<br />
<br />
cout<<"Enter the base: "<<endl;<br />
cin>>base; <br />
cout<<endl;<br />
cout<<"Enter the exponent: "<<endl;<br />
cin>>exponent; <br />
cout<<endl;<br />
<br />
<br />
cout<<"Calling the RECURSIVE function...."<<endl;<br />
startclock = clock();
ans=powerRECURSIVE(base,exponent);<br />
endclock = clock();
cout << "NonRecursive Time: " << (endclock-startclock) << endl;<br />
cout<<ans;<br />
}<br />
<br />
int powerRECURSIVE(int n, int k){<br />
if(k==0) return 1;<br />
int m=k>>1;<br />
int z=powerRECURSIVE(n,m)*powerRECURSIVE(n,m);<br />
if(k && 1)return z*n;<br />
return z;<br />
}
GabyGirl
|
|
|
|
|
I don't really know what you mean by O(n lg n): which n are you talking about? Anyway, powerRECURSIVE can be greatly improved by replacing
int z=powerRECURSIVE(n,m)*powerRECURSIVE(n,m);
with
int z=powerRECURSIVE(n,m);
z=z*z;
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
On my recursive function, I made a mistake:
GabyGirl wrote:
int z=powerRECURSIVE(n,m)*powerRECURSIVE(n,m);
if(k && 1)return z*n;
return z;
I meant [BITWISE AND]
if(k&1) return z*n;
excuse the inconvenience....
GabyGirl
|
|
|
|
|
Where is this program in n lg n ?
I think the main point here should be the calculation by multiplication, but your function gets the base as n ?
So isn't it in O(1) considering n ?
When I look at k it's already in O(lg k). Everytime the recursive function is called m=k>>1 makes the new exponent 1/2 the size. So it should be in O(lg k)
If you think that it is in O(k lg k) because of the times that you measured, then it's just because of the line that Joaquin already pointed out.
WIthout that correction you'd win nothing, because the function does get called twice calculating the same result twice.
|
|
|
|
|
I was wondering I see many registry classes and such for to write to registry, read registry, ect. However I have never seen any code on how to search the registry for differn't values like lets say I wanted to search tne enitre registry for a key name or specific data how would you go about doing that?
- LiquidKnight
|
|
|
|
|
When you record a CD on a CD-R, the cd gets a serial number which changes from one to another.
Is there a way to copy/image/duplicate a CD with the same serial number?
Regards,
Sassan
|
|
|
|
|
I hope you're not trying to pirate something.
CloneCD will do it. google.
#include <beer.h>
|
|
|
|
|
Hello,
I've to use a callback function in my project:
VOID WINAPI RasDialFunc(UINT unMsg, RASCONNSTATE rasconnstate, DWORD dwError);
I wanna know can i define it as member function for a dialog ?
In fact i wanna use some dialog's member variables inside the callback function ...
What's your idea ?
Regards,
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hadi,
A member function cannot be a Callback function since it should have a global scope
|
|
|
|
|
The callback function must be declared in the class as static , in order not to receive the implicit this argument. This makes the class members inaccessible from the member function unless you pass the this pointer as an argument. Looking at your function, I can see no eligible argument... But this is by no means impossible. I have done it before.
|
|
|
|
|
But this is by no means impossible
You means: we can pass this even if the functions have no available for it ?????
Ex: static void CallbackA(UINT nMsg)
Can you call:
CallbackA(WM_...,this);
?????
I'm a Vietnamese student
|
|
|
|
|
No, I mean that usually API callback functions have an LPVOID argument that may be used for this. If I understood your question, you meant API callback functions, right?
|
|
|
|
|
If you need access to the member functions you can also declare a static pointer of the class' type and assign it the this pointer.
class Foo {
public:
Foo () { this_ = this; }
void Bar () { ... }
static MyCallBack ( ... ) {
this_->Bar ();
}
private:
static Foo * this_;
}
|
|
|
|
|
I don't know about your callback function. But commonly, we usually pass 'your dialog' pointer as a function's parameter. With this pointer, we can access everything in your dialog.
But in your callback function, where is input parameter ?
I'm a Vietnamese student
|
|
|
|
|
I am creating a DialogBar, however I have to assosiate the DialogBar resource with the View Class because it needs to be able to access data members from the view. however now I have a problem.. I need to be able to figure out how to retrive the m_wndDlgBar data member from the frame. so I can add code in my view as such
CSliderCtrl* pSlide = (CSliderCtrl*)m_wndDlgBar.GetDlgItem(IDC_DIALOG_BAR);
any help would be appreciated
|
|
|
|
|
There are several solutions. One solution is to class a function in view. Another solution is messages.
Kuphryn
|
|
|
|
|
Can you give a little more detail on either method.
I tried creating a public function in CMainFrame such as
CToolBar& GetToolBar(){return m_wndToolBar;}
then tried to access CMainFrame::GetToolBar()
but of course that didn't work..
|
|
|
|
|
One solution to accessing main frame is AfxGetMainWnd().
Kuphryn
|
|
|
|