|
Could you or Mr Pazzuzu post the code for ex03aView.cpp::OnDraw ?
Mr Pazzuzu wrote:
TemporaryDc is created locally in "ex03aView.cpp::OnDraw"
I suspect OnPrepareDC is not being called for TemporaryDc , but it's just a hunch
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
Could you or Mr Pazzuzu post the code for ex03aView.cpp::OnDraw?
sure, here it is (pssst, there's no ex03aView.cpp fil e in the project ; i found this into pagesView.cpp) :
void CpagesView::OnDraw(CDC* pDC)
{
CpagesDoc* pDoc = GetDocument();
CSize sizeTotal;
sizeTotal.cx = 80;
sizeTotal.cy = 80;
CRect rect;
GetClientRect(&rect);
MemDc tempDC(pDC,&rect);
int pageWidth = 800;
int pageHeight = 800;
int pageGap = 5;
int pageNumber =3;
SIZE size;
size.cx = 1000;
size.cy = (pageHeight*3)+100;
tempDC->Rectangle(CRect(0,0,pageWidth,pageHeight));
tempDC->TextOut(0,pageGap,"This is the first line on the FirstPage");
sizeTotal.cx *= MulDiv(m_textMetrics.tmAveCharWidth, m_iZoomFactor, 100);
sizeTotal.cy *= MulDiv(m_textMetrics.tmHeight, m_iZoomFactor, 100);
SetScrollSizes(MM_TEXT, sizeTotal);
}
thanks for answering
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Ok. He's using a class named MemDc, which I suppose is the one doing the actual no-flicker work.
Anyway, I'd just point Mr. Pazzuzu to this post[^], which might be of help, and let him post something here if he needs more help.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
|
In the MSDN example, I can see in order to ensure only one thread access a resouce, we use:
CSingleLock singleLock(&m_CritSection);
singleLock.Lock();
// resource locked
//.usage of shared resource...
singleLock.Unlock();
However, since CCriticalSection (inheritance from CSyncObject) already have a Lock method memeber, cannt we just do?
m_CritSection.Lock();
// resource locked
//.usage of shared resource...
m_CritSection.Unlock();
Thanks!
|
|
|
|
|
A critical section is a nice way to control access to a section of code, not really a resource. (Unless, all access to that resources is only in that section of code)
A lock is a nice way to control accesses to an object/resource though different code paths and shared data.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
CCriticalSections are usually (not always) class members or global objects that never go out of scope. So if you use CCriticalSection::Lock() you have to remember to call CCriticalSection::Unlock(). This can be tricky to implement if you code can take many divergent paths inside the lock. Using CSingleLock makes this much easier as you would normally declare the CSingleLock inside a function or loop or some other small bit of code where it goes out of scope and is destroyed when no longer needed. CSingleLock automatically unlocks the sync object from within its destructor, you do not have to explicitly call CSingleLock::Unlock().
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I am using .NET with and MFC application.
I have 2 List Boxes on my main dialog. I want to change the color of just one of them to a "pink" for error state. Here is what I have so far....., but it is changing the color of both list boxes to the color.
In the constructor of my main dialog...
m_pEditBkBrush = new CBrush(RGB(255, 200, 200));
HBRUSH CPPMLAnalyzerDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
/*HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
pDC->SetBkColor(RGB(10,100,100));
// TODO: Return a different brush if the default is not desired
return hbr;*/
switch (nCtlColor) {
case CTLCOLOR_LISTBOX:
pDC->SetBkColor(RGB(100, 100, 100));
return (HBRUSH)(m_pEditBkBrush->GetSafeHandle());
default:
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
/*pDC->SetBkColor(RGB(100, 100, 100));
return (HBRUSH)(m_pEditBkBrush->GetSafeHandle());*/
}
}
As you can see, I am trying to set the background color and then return the CBrush from before.
Not sure what I am doing wrong.
Thanks,
Josh
|
|
|
|
|
goodoljosh wrote:
but it is changing the color of both list boxes to the color.
OnCtlColor receives a CWnd* pWnd parameter which points to the control asking for the color. You should check this parameter and only change the color when pWnd is the one you want to affect.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
goodoljosh wrote:
Not sure what I am doing wrong.
The OnCtlColor() method is called for every control. You need to look at the pWnd parameter. Change to something like:
case CTLCOLOR_LISTBOX:
if (pWnd == &listbox_that_i_want_to_change)
pDC->SetBkColor(RGB(100, 100, 100));
return (HBRUSH)(m_pEditBkBrush->GetSafeHandle()); Another solution is to derive your own class from CListBox and do the coloring in it. Then your dialog can have one CListBox member and one CPinkListBox member.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thank you for replying, but I have one more question...
You say if (pWind == &lisboxthatiwanttochange), but how can I compare them? Is there a member of CWnd that I can compare to the INT ID of my listbox?
|
|
|
|
|
goodoljosh wrote:
...how can I compare them?
Exactly as I showed, except that you'd want to use the name of the member control variable and not the name I made up.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Here is what I did....
if (PWnd == &m_wndListBox) (m_wndListBox is the CListBox variable that I use to add strings to the List Box)
but it still changed both boxes to pink
|
|
|
|
|
Got it, thanks.
Here is what was happening. In the constructor, it was changing the both boxes to pink.
When I added the comparison, I didn't realize that it was there that the comparison was happening. I changed the constructor to be white, and then on the comparison, changed just the one to pink. It worked exactly like I wanted....
Thanks for everything.
|
|
|
|
|
Hi everyone.
im sure most of you have heard, seen or installed the Gmail drive namespace extension found at http://www.viksoe.dk/code/gmail.htm
its a great little app.
what I am trying to do is build small open source app ontop of the gmail drive which would enable a little more control when transferring files between the local drive and gmail drive. what i have in mind is a similar interface to ftp clients.
anyway at first glance i thought this would be quite easy. I am coding in visual Studio using C++ i opened a new MFC project. and implemented a new CFileDialog class this worked fine and it recognises the Gmail drive but thats as far as i can get.
theres 2 issues firstly
when i select the Gmail drive it treats it as a file not a folder(so it wont actually log onto gmail to see the files currently located on the Gmail Drive).
and 2ndly
when i look at the path returned from the CFileDialog i get ?::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{2B3453E4-49DF-11D
but when i try to copy a file to this location i get an error (obviosly as this is not a vaild windows file location)
(just to note if i use any win32 application and try to open or save directly to the gmail drive the same errors occur. this seems to be a common problem for all programs.)
i have never used shell namespace extensions before so am not 100% sure where to go from here.
perhaps there is a way to turn the returned string into a valid windows file location.
or is there a class already out there that works well with namespace extensions allowing files to be copied from one to another.
the unfortunate thing is i dont have the source code for the gmail drive shell extension. so until i have that this project may never get off the ground.
If any1 has any advice or ideas on how to tackle this problem im all ears.
thanks
|
|
|
|
|
well i have worked out the first problem of not being able to see the files this can be accomplished using SHBrowseForFolder.
and i am still working on being able to copy the files from gmail drive to HD.
|
|
|
|
|
Can anyone tell me what is the proper way to position a toolbar (actually a DialogBar, but the code is very similar) to the right of an existing toolbar? When I use code like:
m_slideBar.Create( this, IDD_SLIDETOOL, CBRS_TOP, IDD_SLIDETOOL );
m_slideBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_slideBar);
It puts the toolbar on the top of the screen, underneath the normal toolbar.
I can use GetWindowRect(&rc1) to get it’s position, but I can’t seem to move it properly. I tried MoveWindow(rc1) but that doesn’t do the job properly. First of all, it leaves a blank “bar”, i.e. a blank space, where m_sliderBar was. Second, it doesn’t show up until I undock the first toolbar. It then appears and I can redock the first bar again.
I’m sure there must be some accepted way of doing this. I just don’t know what it is. Any help would be greatly appreciated.
Thanks,
Ilan
|
|
|
|
|
I think this [^] article will help.
|
|
|
|
|
Cedric,
Thanks for the help. I was confused by the rect.Offset(1,0) in what it really meant. It means to shift the rectangle 1 pixel to the right. Why 1 pixel, I wondered?
In truth, you can get a better result if you shift it by the size of the first toolbar plus 2 pixels. By shifting only 1 pixel it causes the second toolbar to be smack up against the first, with no space to breath. Adding the extra 2 pixels gives a nicer look.
Thanks again,
Ilan
|
|
|
|
|
Is it possible to find out what type of account the user running your application has, ie. whether they are admin/super-user or just a user?
|
|
|
|
|
PCHUserSettings.IsAdmin
The IsAdmin property retrieves a Boolean value that indicates whether the user is logged on as an administrator.
|
|
|
|
|
Determining what group(s) a user belongs to is not the same thing as finding out if they are an administrator or not. For the former, check out NetLocalGroupGetMembers() . For the latter, check out MSDN article Q118626.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks for your replies, I will check it out
|
|
|
|
|
How do you people manage resources when using a source control system ?
here, we always end up having duplicate IDs ( same number for 2 or more different IDs )
We are using SubVersion; so everyone can locally modify the resources without knowing what others are doing; and when updating, the files get merged without problem.
I could ask our IT team to upgrade to the latest SubVersion which support file locking, but that might take a long time to do.
The problem is that we are doing large amount of UI, and each one of us is modifying those files.
Any Ideas, Suggestions, Links ?
I have to look at Anna's
ResOrg[^], any feeback on that tool ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
We also have numerous projects, with many people possibly modifying the resources at the same time (on different branches of source control). Eventually these branches are merged into the mainline code, resulting in duplicate resource IDs.
To resolve the issue, I wrote some macros (for VC++ 6.0) that will allow you to edit the resource.h file, select any portion of the resource symbols, and then it will renumber them with a user-specified starting number.
It only requires that someone take the responsibility to renumber the resources after merges - and we assign that to the developer that made the merge.
Here's the macros I use:
Sub RenumResType()<br />
'DESCRIPTION: Renumber resource IDs sequentially for a specified type of resource<br />
RType = InputBox("Enter the type of resource you want to renumber?" + vbLf + vbLf +_<br />
"Example: IDC_ or IDD_" + vbLf +_<br />
"Be sure to include the underscore if needed.", "Resource Type", "IDC_")<br />
if len(RType) = 0 then<br />
Exit Sub<br />
end if<br />
<br />
iStart = InputBox("Enter the starting resource number you want to use", _<br />
"Starting Resource ID", "1000")<br />
if len(iStart) = 0 then<br />
Exit Sub<br />
end if<br />
i = iStart<br />
<br />
<br />
ActiveDocument.Selection.StartOfDocument<br />
ActiveDocument.Selection.SelectLine<br />
ActiveDocument.Selection.SelectAll<br />
StartLine = ActiveDocument.Selection.TopLine<br />
EndLine = ActiveDocument.Selection.BottomLine<br />
ActiveDocument.Selection.StartOfDocument<br />
for lineno = StartLine To EndLine<br />
ActiveDocument.Selection.SelectLine<br />
CurrText = ActiveDocument.Selection<br />
pos = InStr(CurrText, RType)<br />
if pos > 0 then<br />
ActiveDocument.Selection.EndOfLine<br />
ActiveDocument.Selection.WordLeft dsExtend<br />
ActiveDocument.Selection = i<br />
i = i+1<br />
end if<br />
ActiveDocument.Selection.StartOfLine<br />
ActiveDocument.Selection.LineDown<br />
Next<br />
ActiveDocument.Selection.StartOfDocument<br />
End Sub<br />
<br />
Sub RenumSelRes()<br />
'DESCRIPTION: Renumbers the selected resources sequentially<br />
CurrText = ActiveDocument.Selection<br />
if Len(CurrText) = 0 then<br />
MsgBox "No text has been selected"<br />
Exit Sub<br />
end if<br />
<br />
iStart = InputBox("Enter the starting resource number you want to use", _<br />
"Starting Resource ID", "1000")<br />
if len(iStart) = 0 then<br />
Exit Sub<br />
end if<br />
i = iStart<br />
<br />
StartLine = ActiveDocument.Selection.TopLine<br />
EndLine = ActiveDocument.Selection.BottomLine<br />
for lineno = StartLine To Endline<br />
ActiveDocument.Selection.GoToLine lineno<br />
ActiveDocument.Selection.SelectLine<br />
CurrText = ActiveDocument.Selection<br />
pos = InStr(CurrText, "#define ")<br />
if pos > 0 then<br />
ActiveDocument.Selection.EndOfLine<br />
ActiveDocument.Selection.WordLeft dsExtend<br />
ActiveDocument.Selection = i<br />
i = i+1<br />
end if<br />
Next<br />
ActiveDocument.Selection.GoToLine StartLine<br />
End Sub<br />
As you can see, there are two macros here - one will renumber all resources of a given type (IDC_, or IDS_, etc) and the other renumbers all resources you have selected.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|