|
put AfxGetInstanceHandle() to get a HINSTANCE
WUSIWUG
|
|
|
|
|
Ok. Now I have:
SetCursor(LoadCursor(AfxGetInstanceHandle(),IDC_WAIT));
I also tried:
SetCursor(LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_WAIT)));
And yet no cursor change
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
to really change the cursor you should handle the OnSetCursor function (WM_SETCURSOR, i think).
BOOL CISSimpleViewerDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (pWnd==(CWnd *)this)
{
if (nHitTest==HTCLIENT)
{
if ((message==WM_MOUSEMOVE) || (message==WM_LBUTTONDOWN) || (message==WM_LBUTTONUP))
{
SetCursor(AfxGetApp()->LoadCursor(IDC_OPENHAND));
return TRUE;
}
}
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
SetCursor() is not persistent, the new cursor only lasts until the next time your window gets a WM_SETCURSOR message, which is sent every time the mouse moves in your window. If you don't handle that message, DefWindowProc() resets the cursor to the arrow.
Since you're using MFC, just use CWaitCursor .
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Is there anyway that I could print pdf file without using Adobe Acrobat???
|
|
|
|
|
php has some libs for doin this i think but im not sure if they work ok or whatnot
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" what i do who i am
|
|
|
|
|
There are several companies that make PDF libraries that you can use. The only one I have experience with is Zeon (http://www.zeon.com.tw). It does a pretty good job printing, although they render everything as GDI, so Postscript printers don't work as well as they should. They also have a great library for building PDFs that is very similar to Adobe's now-discontinued PDFLib.
I understand there are several open source projects to build similar things, but I haven't spent much time evaluating them.
|
|
|
|
|
Hi,
I have a class derived from CStatic. When cursor is over the control i want the text to change color. To manage this i had override OnPaint. It works fine but the problem is i also want this control to be capable of displaying icons.
I tried the following code but it didn't work:
if( m_hIcon )
{
CStatic::SetIcon( m_hIcon ); (Line 1)
}
else
{
// If no icon is specified just draw the text
dc.DrawText( str, str.GetLength(), rect,
DT_CENTER | DT_VCENTER | DT_SINGLELINE );
}
m_hIcon, is spcified by user by the overriden SetIcon method:
HICON CTableTextStatic::SetIcon(HICON hIcon)
{
m_hIcon = hIcon;
return m_hIcon;
}
Can you tell me what am i doing wrong here?
I also tried replacing "Line 1" above with the below:
dc.DrawIcon( rect.Width() / 2, 0, m_hIcon );
It works but i want the icon to be centered and i couldn't find a way to get icon's size.
And with this way, it draws the icon even if SS_ICON style is not specified. Does that mean using DrawIcon is not a nice way to do it?
Sorry for the long post. It would be great if you could help me on this one.
Thank you in advance.
|
|
|
|
|
I cannot try it right now, but maybe modyfing the style of the control will work:
if(m_hIcon){
ModifyStyle(0,SS_ICON);
}
else{
ModifyStyle(SS_ICON,0);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for replying and sorry for not mentioning the line i created the control:
<br />
CTableTextStatic *pSta = new CTableTextStatic;<br />
pSta->Create( "Test", WS_CHILD | WS_VISIBLE | WS_THICKFRAME | SS_ICON | SS_CENTERIMAGE | SS_NOTIFY, CRect( 525, 100, 650, 125 ), this, 12654 ); <br />
pSta->SetIcon( AfxGetApp()->LoadIcon( IDR_MAINFRAME ) );<br />
So I already declared its style to display icons.
For drawing the icon, there are some nice methods of CDC class such as StrechBlt but instead of HICON i am allowed to use HBITMAP.
|
|
|
|
|
I solved my problem. In case, in the future someone faces the same problem i decided to write how i solved it:
Instead of using DrawIcon method of CDC, i used DrawIconEx.
if( m_hIcon )
{
::DrawIconEx( dc.m_hDC,
( rect.Width() / 2 - m_nIconWidth / 2 ),
( rect.Height() / 2 - m_nIconHeight / 2),
m_hIcon,
m_nIconWidth,
m_nIconHeight,
NULL,
NULL,
DI_IMAGE );
}
else
{
if( str )
{
dc.DrawText( str, str.GetLength(), rect, DT_CENTER
| DT_VCENTER | DT_SINGLELINE );
}
}
and SetIcon function
void CTableTextStatic::SetIcon(HICON hIcon, int width, int height)
{
m_hIcon = hIcon;
m_nIconWidth = width;
m_nIconHeight = height;
}
This way, i can specify any size for icon and it resizes( stretches or compresses) the icon automatically. And it draws centered.
|
|
|
|
|
I want to use some of the symbols of the font webdings or wingdings on a button, I can change the font of the button to all the outhers but no to this ones
anyone knows why?
Casa.Sapo.pt
|
|
|
|
|
I've seen somebody doing this:
switch(msg)
{ case WM_INITDIALOG:
{
return TRUE;
}
`:
{ int id=LOWORD(wParam);
if (id==IDOK)
{
}
if (id==IDOK || id==IDCANCEL) EndDialog(hwnd,id);
} break;
}
What I don't understand is the `: . My visual studio can't compile it, unrecognized patati patata...
What does the programmer mean by it?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
You are dreaming. You have never seen anyone do anything like that since it's illegal code.
Maybe you have seen some one do it with "ticks" (') added round the "back-tick" or in a web-page that for some reason f***ed it up, or for a WM_CHAR with ESC (ASCII 27, which obviously can't be displayed)?
But again, you have _never_ seen C or C++ code that worked look like what you displayed.
|
|
|
|
|
|
A typo or some problem with formating the code in HTML editor.
Pavel
Sonork 100.15206
|
|
|
|
|
When i get to a certain point in my code:
acmDriverOpen(&hacm, hadid, 0);
I get a "User breakpoint called from code at 0x000XXXX" message and in the Output windows it says:
HEAP[MP3.exe]: Invalid Address specified to RtlFreeHeap( 01560000, 01564260 )
Unhandled exception at 0x77f767cd in MP3.exe: User breakpoint.
I would really appreciate it if someone told me what this means and possibly how i can fix it.
Thankyou
-Rune
|
|
|
|
|
Other than repeated trial and error, how can I figure out the location of my control in code? I am putting two buttons on a CDialog that I want to line up under a couple of CListCtrls. I dont know how to size these since I dont know what areas I am working with. Does one somehow get the number of pixels manually from the IDE? Like if I knew the form is 600 pixels high, I would put my button at 500 pixels if its height is 50. I'm using stuff like:
m_startsearch.MoveWindow(580,30,70,30);
m_cancelsearch.MoveWindow(580,65,70,30);
I dont know if getclientrect is helpful in this case since I want to position these buttons relative to two other controls on the form, which by trial and error I've positioned the way I want. So if I knew the actual number of pixels in my form I could do the adjustments I suppose. Any ideas on how to make this process more scientific?
Thanks,
ns
|
|
|
|
|
You can use CWnd::GetWindowRect to get the location of the controls you wish to align to.
|
|
|
|
|
|
Hi All,
Just wondering if anyone knows a simple way to reuse an existing form view as a dialog, without having to create a new CDialog derived class from scratch to do it.
Thanks,
Aaron
|
|
|
|
|
It's not possible to reuse CFormView as a dialog. What should be possible is to embed a dialog (modeless) in a CView derived class (not CFormView) and alternatively using as a modal one.
Pavel
Sonork 100.15206
|
|
|
|
|
Hi guys.
Do you know a simple way to identify uniquely a computer independently of the OS? What can I use in MFC to do this?
Best Regards
|
|
|
|
|
think that exists some key on registry (i dont know where)
if you have all your windows licensed you have no problem , use the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId
if this is not the case then i think you can use:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate
it will be very dificult (almost impossible) to find two pc with the same installdate on a local network (anless you have used norton ghost or somenthing like that)
Casa.Sapo.pt
|
|
|
|
|
its better to consider the Disk Volume label/processor ID
there s various API s to query the details..
WUSIWUG
|
|
|
|