|
lol I just saw and used that from the MSDN and it worked. Thanks for confirming thats the right one to use!
|
|
|
|
|
You are welcome!
BTW. Is MSDN really so funny to "lol", or just my answer ?
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
I've skewed the meaning of "lol" so much that I end up including it in almost every post even if I have a straight face, but if I had to literally have a chuckle at your answer then it would have to be corniest joke I would have ever laughed at
|
|
|
|
|
Hi,
I have a login dialog on which there is a logo. In the OnPaint() function I have added some code to make the logo transparent.
But everytime I minimize the login dialog box and then maximise it again, I get Debug assersion failure. But if I do not minimize it, then the rest of the program works fine.
I am not able to figure out what I must do to correct this. If I block out the code in the OnPaint() function, this problem dosen't occure.
void CLogin::OnPaint()
{
CPaintDC dc(this);
CRect rect;
GetDlgItem(IDC_STATIC_MJ)->GetWindowRect(&rect);
ScreenToClient(&rect);
COLORREF clrDlg = GetSysColor(COLOR_BTNFACE);
m_bitmap.LoadBitmap ( IDB_MJ_SOFTWARE ) ;
CBrush mybrush, *oldbrush ;
mybrush.CreateSolidBrush ( clrDlg ) ;
oldbrush = dc.SelectObject ( &mybrush ) ;
Display ( &dc, rect.left , rect.top , RGB ( 255, 255, 255 ) ) ;
mybrush.DeleteObject( ) ;
dc.SelectObject ( oldbrush ) ;
}
Please can you tell me what I am doing wrong here.
Thanks,
Tara
Fortitudine Vincimus!
-- modified at 7:20 Sunday 2nd July, 2006
|
|
|
|
|
Aside note: in your code it's not even necessary to call mybrush.DeleteObject() because anyhow it is deleted when out-of-scope.
Ovidiu Cucu
Microsoft MVP - Visual C++
-- modified at 3:23 Monday 3rd July, 2006
|
|
|
|
|
Thanks a lot.
Its working now.
I used GetSafeHdc() but it was still giving error. But I understood that before loding a bitmap to m_bitmap , I must free it. So I used m_bitmap.DeleteObject(); and, of course the second point that you stated.
Thanks once again.
Fortitudine Vincimus!
|
|
|
|
|
Oups, I made a mistake in my previous answer.
I just have corrected it.
Also as long as we have not a CBitmap pointer, you can directly test m_hObject member instead of call GetSafeHandle, like WhiteSky already suggested.
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
SO, the reason that the assersion failure occurs is that when the dialog is minimised and then maximised, and the onPaint() function is called, the bitmap object tries to load an already loaded object. Is that correct?
Therefore, one must either delete the object before calling Load or check whether it is NULL, and call Load only if it is.
Fortitudine Vincimus!
|
|
|
|
|
You can use
if (m_bitmap.m_hObject==NULL) <br />
m_bitmap.LoadBitmap ( IDB_MJ_SOFTWARE ) ;
whitesky
|
|
|
|
|
Hi all,
I am having trouble to calculate precisly how many visible lines (according to the font currently selected) i have in my CRichEditCtrl derived class.
here is the code snippet:
// this event is EN_CHANGE
void CMyRichEditCtrl::OnEdtChange()
{
CDC* pDC = GetDC();
int nTxtLen = GetWindowTextLength();
SetSel(nTxtLen,nTxtLen);
CHARFORMAT2 cf;
GetSelectionCharFormat(cf);
int nFontSize = cf.yHeight / 20;
int nFontHeight = -MulDiv(nFontSize, GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 72);
nFontHeight *= -1;
ReleaseDC(pDC);
CRect rc;
GetRect ( rc );
int nVisibleLines = rc.Height() / nFontHeight;
nVisibleLines -= 3;
int nTotalLines = GetLineCount();
int nDelta = nTotalLines - nVisibleLines;
}
trouble is , the calculation i get is incorrect, especially when i change the font size.....
can any1 help?
thanks in advanced
Rami
|
|
|
|
|
Hi,
I'm looking for function which works reverse of QueryDosDevice. I've got a "\\Device\\HarddiskVolume1" and I want to translate it to drive letter.
-----------
Mila
|
|
|
|
|
<br />
TCHAR GetDriveLetter(LPCTSTR lpDevicePath)<br />
{<br />
TCHAR d = _T('A');<br />
while(d < = _T('Z'))<br />
{<br />
TCHAR szDeviceName[3] = {d,_T(':'),_T('\0')};<br />
TCHAR szTarget[512] = {0};<br />
if(QueryDosDevice(szDeviceName, szTarget, 511) != 0)<br />
if(_tcscmp(lpDevicePath, szTarget) == 0)<br />
return d;<br />
d++;<br />
}<br />
return NULL;<br />
}<br />
|
|
|
|
|
im trying to make a scrolling text im using scrollwindow and it moves back and forth but when it goes from left to right if the text is say "hello" it looks like hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhello how can i get it to look right and not repeat the first letter?
|
|
|
|
|
To avoid such nasty hhhhhhhhhhhhhhhhhhhhheadaches, you can take a look at THIS FAQ[^]
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
CMyDialog::PreTranslateMessage()
{
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_UP)
{
m_bUp = TRUE;
pMsg->wParam = VK_TAB;//tranlate into TAB
keybd_event(VK_SHIFT, 0, 0, 0); //press down the shift
}
else if(pMsg->wParam == VK_DOWN)
{
m_bUp = FALSE;
pMsg->wParam = VK_TAB;//tranlate into TAB
}
else
m_bUp = FALSE;
if(IsDialogMessage(pMsg))
return TRUE;
}
else if(m_bUp)
{
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);//Release SHIFT
m_bUp = FALSE;
}
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|
|
Could someone tell me what open mode I can use to write data only to the end of my already created (existing) file? should I use iso::trunc?
~Moujan
-- modified at 1:59 Sunday 2nd July, 2006
|
|
|
|
|
ios::app
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall.
Awasu 2.2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
|
Could some one tell me how I can prevent duplicate definitions in my program. I mean should I use something like #definemyClass or should I use provate keyword.
Thanks, Moujan
|
|
|
|
|
Typically in your .h header file you would put:
#ifndef _MY_CLASS_H
#define _MY_CLASS_H
class MyClass
{
...
};
#endif // _MY_CLASS_H
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Thanks for replay.
Moujan
|
|
|
|
|
Hi,
I am looking for System Wide hook for File Save as dialog.
What I want is to show more data inputs to enter in the dialog such as : a dropdown with some values, a date control etc.
It is not necessary it be the same dialog, it could be a new dialog all together with customized UI (preferrable) and gets some of the dropdown values from a database.
Creating the UI controls / Getting the information from database will not be issue at all.
What I am specifically looking for is how to make file save as hook, how to show a modified OR a new dialog all together (preferable) in all Apps when file save / file save as is executed ?
Have already seen the articles on System Wide hooks. They are very good but I am looking on how to do this specific application scenerio.
I will really appreciate your suggestions.
Thanks
Mo
|
|
|
|
|
Take a look at:
www.catch22.net/source[^]
I've got a sample there called 'report-view', it shows how to do a system-wide modification to all Open/Save dialogs and change the view to 'detail-view' in these windows.
James
http://www.catch22.net
|
|
|
|
|
Thanks a lot for your response James. I downloaded the source and will have a look at it.
I also liked the content of your web site.
Mo
|
|
|
|
|
Hi all,
When I click in a label in my (heavily subclassed) ListView, I get the following DLL:s loaded:
<br />
Loaded 'C:\WINDOWS\SYSTEM32\winmm.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\fireface_mme.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\setupapi.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\wintrust.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\crypt32.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\msasn1.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\imagehlp.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\EMGA8U2K.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\version.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\wdmaud.drv', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\wdmaud.drv', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\MSACM32.DRV', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\msacm32.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\SYSTEM32\midimap.dll', no matching symbolic information found.<br />
The loading of the libraries takes about 1 sec, which is not acceptable. The app does not use any multimedia features, and is not based on MFC or any other framwork (pure Win32 API calls).
I have done some research, but is now totally at a loss. Any suggestions will be appreciated!
Thanks!
PS.
Fireface800 is my audio I/O unit, a beautiful piece of hardware if you ask me
|
|
|
|