|
can we create a rich colored icon - i.e. 256 colors or more - for VC?
includeh10
|
|
|
|
|
hi,
you can, but not with resource editor supplied with VC.
GSte
|
|
|
|
|
Is it possible to use the standard CFileDialog, and dynamically hide certain controls before it is displayed? I am able to create a hook function to trap the WM_NOTIFY/CDN_INITDONE message sequence, but cannot seem to grab the handles for the controls on the dialog at this stage. Can anyone enlighten me?
I've tried several different versions of the following code, to no avail. What am I doing wrong?
CString CCustomizedDialog::GetFolder()
{
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL; //or any valid parent window handle.
ofn.hInstance = AfxGetInstanceHandle(); //or your hinstance variable if you are not using mfc support.
ofn.lpstrFilter = _T("Text Files\0*.txt\0\0"); //modify this for any other filter.
ofn.lpstrCustomFilter = NULL;
ofn.nFilterIndex = 0;
ofn.lpstrFile = new TCHAR[256];
memset(ofn.lpstrFile, 0, 256 * sizeof(TCHAR));
ofn.nMaxFile = 256;
ofn.lpstrFileTitle = NULL;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = NULL;
ofn.Flags = OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE;
ofn.lpfnHook = OFNHookProc; //Custom hook procedure.
ofn.lpTemplateName = MAKEINTRESOURCE(FILEOPENORD);
GetOpenFileName(&ofn);
CString theReturnString = ofn.lpstrFile;
delete [] ofn.lpstrFile;
return theReturnString;
}
//Custom hook procedure stub. Must remain outside of the class
UINT CALLBACK OFNHookProc(
HWND hdlg, // handle to child dialog box
UINT uiMsg, // message identifier
WPARAM wParam, // message parameter
LPARAM lParam // message parameter
)
{
// set a flag so we know when the dialog has been initialized
static BOOL isInitialized;
CEdit* theEditBox;
//Do your message processing here.
//Return 0 if you need the default dialog box procedure to process
switch (uiMsg)
case WM_NOTIFY:
{
AfxMessageBox("Notify was caught!");
if(isInitialized == TRUE)
{
HWND theParent = GetParent(hdlg);
if(theParent != NULL)
{
theEditBox = (CEdit*)GetDlgItem(theParent,edt1);
theEditBox->SetWindowText(_T("Readme.txt"));
}
}
/// catch CDN_INITDONE message so we can
/// change the look of the dialog
if(((OFNOTIFY *)lParam)->hdr.code == CDN_INITDONE)
{
AfxMessageBox("INITDONE was caught!");
isInitialized = true;
HWND theDlg = GetParent(hdlg);
CString theMsg = "The ParentHWND: ";
// theMsg += theDlg;
// AfxMessageBox();
}
}
return 0;
}
Thanks,
--Mark
|
|
|
|
|
You might consider using Spy++ to display the dialog and then get info on the control in question - this will give you the control's ID, which you could then use with the GetDlgItem() call, passing in the ID that Spy++ discovered.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Hi Jim,
Thanks for the quick reply. I think the problem is with getting a handle to the actual dialog on which the control is drawn. I have to pass this handle (I believe) to the GetDltItem() function. I have tried both the hdlg parameter, and GetParent(hdlg) in the hook function, but neither one seems to work. I have been looking at Spy++, and the handle I get for the actual dialog does not match either one of these...
I will look at it again, though. Thanks.
|
|
|
|
|
Since you're using MFC (or it appears so), it might be a little easier if you subclass CFileDialog and overload it's OnInitDialog member function. In the subclass OnInitDialog function, you can use GetDlgItem(), using the control IDs that you obtain using Spy++, to get pointers to the dialog controls you want to hide.
If you do this way, you won't need a special dialog proc and you won't have to deal with the OPENFILENAME structure.
|
|
|
|
|
Yes, thank you. I had originally tried doing this, but was unable to get handles to the controls on the dialog. I was using the constants defined in dlgs.h (edt1) to grab handles (GetDlgItem()). Are these constants not correct? I'm confused as to why I would need to use spy++ to get the ids...are they not constant?
Thanks for all the help.
|
|
|
|
|
Okay, I tried this, and there are two problems (unless I'm doing something wrong). The first is, spy++ gives me handles to windows, not control id's. The second is, these handles are not constant...they are different each time I bring up the dialog box.
|
|
|
|
|
Yes, you are correct, the window handles will most likely be different each time the dialog comes up. Here's a step by step in Spy++ to get the info you need.
1. Bring up the common dialog having the control you want to hide. Do this before you run Spy++.
2. Run Spy++ and press Alt-F3 (Search for window).
3. On the Find Window, there's a crosshair icon, grab it and drag to the control on the common dialog you want info about. If you need to, you can check the "Hide Spy++" checkbox to get Spy++ out of the way. This will show the Handle and class name. Sounds like you got this far.
4. Now, click on the Ok button on the Find window dialog (in Spy++). The window you're wanting info about should now be selected in the tree view on the "Windows 1" view.
5. Right click on the highlighted item in the tree and select properties. This will bring up another dialog with the information that you need, namely the control ID.
Note that the Control ID is displayed in hex.
Given the Control ID, you can do something like this in your subclass OnInitDialog (example hides the Cancel button):
CWnd* pCancelBtn = GetDlgItem(0x0002);
if (pCancelBtn != NULL)
pCancelBtn->ShowWindow(SW_HIDE);
|
|
|
|
|
Thank you so much for the help. You've lead me in the right direction. The problem was in calling the GetDltItem...I needed to call that for the parent window:
CWnd *theParentWnd = this->GetParent();
CWnd *theEditBox;
// edt1 is defined in <dlgs.h>
theEditBox = theParentWnd->GetDlgItem(edt1);
theEditBox->ShowWindow(SW_HIDE);
This worked! By the way, the ID in spy++ matched that defined in dlgs.h, so I just used it.
Thanks again...whew, what a workout!
|
|
|
|
|
I seem to be running afoul of the TaskManager in some way that I am unaware of.
In the VCF we have the core GUI library that contains an .ICO file that's used in the WNDCLASSEXW struct before calling RegisterClassExW().
I fill it in like so:
WNDCLASSEXW wcex;
wcex.cbSize = sizeof(wcex);
wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wcex.lpfnWndProc = (WNDPROC)wndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = (HINSTANCE)::GetModuleHandle(NULL);
wcex.hIcon = LoadIconW( Win32ToolKit::getInstanceHandle(), L"DefaultVCFIcon" );
wcex.hCursor= NULL;
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = className.c_str();
wcex.hIconSm = NULL;
This works fine. But sometimes when I call up the TaskManager there is no entry for the executable!. Using Alt+Tab, the window icon is there just fine.
It shows in the task bar just fine.
If I change the window icon dynamically by calling
HICON winIcon = //get the HICON image
SetClassLong (hwnd_, GCL_HICON, (LONG)winIcon);
Is this incorrect? Using WM_SETICON seemed to have problems as well.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Hello:
I needed to have an Animated Gif in my program so I included the code from PictureEx which works great except for the following.
I complie using Level 4 which means I get a lot of warnings.
Since including the code from PictureEx I now get 35 warnings for C4663, C4018 and C4100 these all refer to where he is using a Vector template class.
I tried using #pragma warning( disable : 4018 4100 4663 ) but this doesn't help. Tried all forms of this #pragrma and still can't get rid of these warnings.
I never have warnings in my code and can't figure out how to get rid of these that the PictureEx code has caused.
Can anyone help
Thanks
BobVal
|
|
|
|
|
C4663 is caused by an old template class declaration. It is not an actual error, and should not cause errorneous behaviour, but when time goes on and new compilers appear, this declaration form will soon become a syntactical error. The creator of the class should alter the original source code to fix this. You can do nothing (besides directly modifying the source code) to fix it. If the source code license allows it, feel free to do it and post a corrected version to the author.
C4018 is caused by signed/unsigned comparison mismatch. This originally inherits from the way signed and unsigned numbers are handled. In assembly/machine-code, the concept of signed/unsigned does not exist. All numbers are unsigned there. The difference is made by interpreting the value. Consider an 8-bit value (such as a 'char'). If it is a signed char, direct values 0-127 refer to signed values 1...127 and values 128-255 refer to -128...0. It cannot have a value outside of range -128...127. A comparison operation in assembly is a mathematical substraction. If the substraction causes a 'borrow' to happen (don't know the actual math term in english for it), a flag is set. Looking at this flag, the conclusion of greater or not is made, and true/false is returned. It is possible that sometimes, when the numbers are suitable, an errorneous interpretation is made. I cannot outright remember what these conditions are. Lets just say that avoid comparing unsigned and signed numbers whenever possible
C4100 is caused by having an unreferenced parameter in function declaration. This is like having a needed parameter passed to a function and the parameter is never used inside the function, making it irrelevant for the function. It is most obviously a typing error in the source code. Fixing it requires checking the function in question and seeing if a parameter truly is unreferenced, and if it is, removing it from the function definition. Again, a source code change is necessary.
In conclusion, there's nothing you can do to fix these errors without altering the PictureEx source code. But none of them are critical, either, excluding the first one. C4663 might cause an error later on when a new compiler is released that no longer supports the old-style syntax.
Hope this helps.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
THIS WAS ZERO HELP
I KNEW THESE ARE WARNINGS, I Stated this.
I know what the messages mean, I looked them up.
I WANT TO STOP the compiler from generating these warnings.
With the exception of this PictureEx code I have ZERO warnings when I compile my programs. I don't want to fix Microsoft's Vector template class and I don't know how to fix the PictureEx code to get rid of this warnings.
So I have been trying to get the complier to NOT DISPLAY them or IGNORE them when compiling the code.
|
|
|
|
|
All these warnings are coming from Microsoft's templates VECTOR and XMEMORY
I just made the proper changes to them and saved a copy in my local include directory.
At least now I am back to ZERO errors, and maybe some day Mircosoft will release new templates.
|
|
|
|
|
A simple 'no this did not help' would've been adequate. But no matter. You got the problem fixed, so no need for any of this anymore
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Did you try putting
#pragma warning (disable : 4018 100 663)
in your the header file for PictureEx or at the top of your stdafx.h file?
According to MSDN, the compiler will automatically add 4000 to error numbers between 0 and 999.
Don't flame me....yes, I noticed you have already "fixed" this, thought I'd add my 2 cents worth ....
|
|
|
|
|
hi,
for a uni project i need to write some c++ allowing a user to draw to a memory structure - like a bitmap i guess - so that the value of each individual pixel can accessed. initially this will be using the mouse and will be displayed on the screen but will later needs to work on a graphics tablet also displaying the output on the tablet.
I have tried a couple of different approaches:
FLTK - using mouse i can draw pictures but is not drawing to a data structure but instead to the screen so dont know how to access each pixel individually...
have also tried using CBitmaps but cant work out how to draw to them...
ive never programmed in c++ before so do not know what is possible. I am using .NET 2003 as an environment.
please could someone suggest a way of doing this or somewhere to find information on it.
Thanks in advance
Andy
|
|
|
|
|
Do you need to access each pixel individually or just what the user draws? If it is just what is draws and you want it realtime then you can create a shadow bitmap and mirror the drawing logic both on the screen and this bitmap(or whatever device context you wish). If it is only after the user finishes and lets say selects print you could use something like the BitBlt function and copy the drawing area (most likely the client area of the window ) to whatever device context you wish. If you look on MSDN for GDI functions you will find all this information. I am not trying to be vague, I just am not exactly sure what you want to do; maybe if you would rephrase your question I could help more.
|
|
|
|
|
Howdy,
The OnCtlColor function does not seem to do anything for buttons, and scrollbars.
MSDN suggests that by processing the CTLCOLOR_BTN case, the background color for all buttons in a dialog can be set. However when I try this nothing happens.
The function behaves correctly for other controls, such as edit and static controls.
In the OnCtlColor() function I have:
if (nCtlColor == CTLCOLOR_BTN)
{
pDC->SetBkMode(TRANSPARENT);
if(m_buttonBrush)
hbr = *m_buttonBrush;
}
and m_buttonBrush is created earlier.
Is it possible to use this function.. I would really like to avoid making my own custom button control and subclassing from it.
thanks,
Tom
|
|
|
|
|
Hi,
I can vaguely remember, that I also tried to use OnCtlColor a century ago. As far as I can remember, the only colour I cold change was the text colour of that button.
Regards
GSte
|
|
|
|
|
Same here. I could only control the static text, group boxes, and dialog background colors. I just tried again right now and although I do return a brush handle for CTLCOLOR_BTN (and the trace statements I added confirm that), the buttons are drawn using system colors regardless.
I ended up creating a color button class (which I wanted to avoid like you) but turned out to be a good thing because I could then make them a bit fancier (e.g. gradient paint).
|
|
|
|
|
Hi All,
I have the following Problem:
I'm using the MS C++ .NET 2003 Standard Edition on Windows XP Home. I'm not able to create Windows Forms bases applications. If I try to create such a Project I get an error window saying "specified module cannot be found" (translated from german, maybe slightly different in english version).
If I try to add a Form By using File | Add new Element and the select Windows Form I get the same error. The Project is a managed C++ Project.
Another Problem is, that if I start MS VC++ .NET and go to the "My Profile" Page or the "Online ressources Page" I get again error messges telling me that there is an error in the skript which again seems to be caused by the module not found error.
I tried reinstalling MSVC several Times, this did not help. I tried to Install a Professional Version this showed the same behaviour.
Can anyone give me a hint what is going on here?
Thanks in advance,
Ingo
|
|
|
|
|
There's only 2 things I can think of... and they might not be right.
1. Check to make sure "use managed Extensions" is set to 'YES' in your project's properties for the first problem.
2. for the second problem, I had a problem similar to that one before. Somehow one of my test apps was made using a document extension of ".htm" VS.Net seems to use .html pages for its wizards (I guess they're CDHtmlDialog-based). This may not be the problem, but just to check, double-click on a file with an .html or .htm extension and make sure it opens up your browser and not some other application. I had made a BugReporter application that had somehow gotten the .htm extension associated with it, so everytime i double-clicked a .htm file, it opened up my app. VS was having a problem because of this and couldn't open its associated .htm page to go with the dialog
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Hi all
I am facing problem with the following issues:
1.0 Mapping Mode
2.0 ScaleViewport
3.0 SetViewOrg.
I am using QZoomView a class from Codeguru as base class of my view which inturn is derived from CScrollView
Following is the OnPrepareDC function of the My View
Code:
void CPatternView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) <br />
{<br />
<br />
if ((m_Mode == MODE_ANALYSIS && m_AnalysisItem == AN_TIME_WINDOW) || <br />
(m_Mode == MODE_ANALYSIS && m_AnalysisItem == AN_WFR_DIAGRAM))<br />
{<br />
QZoomView::OnPrepareDC(pDC, pInfo); <br />
}<br />
else<br />
{<br />
CScrollView::OnPrepareDC (pDC,pInfo);<br />
pDC->SetMapMode(MM_LOENGLISH); <br />
}<br />
}
And OnPrepareDC of QZoomView
Code:
void QZoomView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)<br />
{<br />
CScrollView::OnPrepareDC(pDC, pInfo);<br />
if (!pDC->IsPrinting())<br />
{<br />
ASSERT(m_Zoom > 0.0f);<br />
int denom(1000);
int num((int)(m_Zoom * (float)denom));<br />
pDC->SetMapMode(MM_ANISOTROPIC);<br />
pDC->ScaleViewportExt(num, denom, num, denom);<br />
<br />
CRect rect;<br />
GetClientRect(&rect);<br />
CPoint pntVO = pDC->GetViewportOrg();<br />
if (m_totalDev.cx < rect.Width())<br />
pntVO.x = (rect.Width() - m_totalDev.cx) / 2;<br />
if (m_totalDev.cy < rect.Height())<br />
pntVO.y = (rect.Height() - m_totalDev.cy) / 2;<br />
pDC->SetViewportOrg(pntVO);<br />
}<br />
}
PROBLEM STATEMENT
This indicates that when I am calling QZoomView::OnPrepareDC then it changes the view settings and then if i am using onpreparedc of CScrollview then content of my view get displaced/shifted horizontally.
I just want to get the view in initial position i.e. the effect of changes made by QZoomView::OnPrepareDC get neglected.
Can you please help me in getting this done?
Sandeep
Leave your mark wherever you go
|
|
|
|
|