|
Yes, that is the idea; short and simple. The only thing I would change in the example is the assignment to NULL, because you immediately assign a value to it after the declaration.
number* n = new number[2];
number* temp = new number[4];
Those are shorter and make more since to me.
P.S. The register keyword is unneeded, because most modern compilers are better at picking register variables than we are and it is free to ignore the suggestion, which is all that keyword is.
Good Luck!
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
How do you get the width of a scrollbar assocaiated to a given control?
|
|
|
|
|
It depends on the type of scrollbar.
If it's a standard scrollbar, you can use GetSystemMetrics().
If it's a scrollbar control, you can use GetWindowRect().
For scrollbars implemented by custom controls, you're on your own
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
in MFC afx.h Ln366,I see this:
#define ENSURE_THROW(cond, exception) \
do { int __afx_condVal=!!(cond); ASSERT(__afx_condVal); if(!(__afx_condVal)){exception;} } while (false)
why do{...}while(false)?
is that equal to this:
#define ENSURE_THROW(cond, exception) \
int __afx_condVal=!!(cond); ASSERT(__afx_condVal); if(!(__afx_condVal)){exception;}
and why use "int __afx_condVal=!!(cond);",is this ensure the value of __afx_condVal is either 1 or 0?
Stay Hungry. Stay Foolish
Thanks Alot!
-- modified at 14:06 Friday 5th October, 2007
|
|
|
|
|
Howdy guys, just a quick question about a small problem I am having in a little chat application I made for the sake of learning.
Currently I want my app to minimize to my tray displaying its icon. I want the window to be hidden completly, I dont want it to appear minimized in the taskbar. If the user wants to open the app he can double click the icon in the tray. I got the animation working, my icon loads in the try, however I cannot hide the window. It minimizes to the task bar below making it appear "miniized". It should be hidden no?
Currently I am using this command I assumed it would hide everything. Any obvious thoughts come to mind on what I might be doing wrong?
ShowWindow(m_hWnd, SW_HIDE);
If you want I can display more code just let me know!
Thanks Alot!
Cliff
|
|
|
|
|
See http://www.codeproject.com/dialog/hidetaskbar.asp
IMNOOPR
|
|
|
|
|
OK going to look into this more. Seems like alot of work just to hide the window out of the taskbar.
|
|
|
|
|
Are you sure you're passing the right HWND to ShowWindow()?
What's style and extended styles does the app's main window have?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yea I have m_hWnd as my main window. I'm passing these styles apon its creation.
WS_OVERLAPPEDWINDOW|WS_VISIBLE
This gets passed into a win32 wrapper class constructor and is saved to m_dwStyles;
Here is my extended style
WS_EX_CLIENTEDGE
m_hWnd = CreateWindowEx (WS_EX_CLIENTEDGE,<br />
m_pClassName, m_pWindowTitle,<br />
m_dwStyles,<br />
m_pRect->left,<br />
m_pRect->top,<br />
m_pRect->right-m_pRect->left,<br />
m_pRect->bottom-m_pRect->top,<br />
NULL, <br />
m_hMenu,<br />
m_hInstance, <br />
(void *)this);
Mark you always seem to save me! Hope you have some ideas for this one. Thank you sir. =)
Cliff
|
|
|
|
|
hmm... I use the same style and, like DavidCrow (except in a different order),
I just do
Shell_NotifyIcon(...)
ShowWindow(SW_HIDE)
Any other window stuff going on?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Just minimizing to the tray, some tooltips, buttons. All standard stuff really. I've been following the stromcode tutorial but pulling what I want in my app as apposed to his portscanner.
I had wanted to have the client drop to the tray and post a balloon when someone messags you. My tray icon works but the apps tays in the taskbar as minimized.
Could it be my animation?
Heres everything I have in the minimize function
void ChatApp::miniMizeTray(const int icon)<br />
{<br />
ANIMATIONINFO anii;<br />
anii.cbSize = sizeof(anii);<br />
SystemParametersInfo(SPI_GETANIMATION, sizeof(anii), &anii, 0);<br />
<br />
RECT desktopRect, thisWindowRect;<br />
GetTrayWndRect(&desktopRect);<br />
GetWindowRect(m_hWnd, &thisWindowRect);<br />
<br />
if (anii.iMinAnimate)<br />
{<br />
DrawAnimatedRects(m_hWnd, IDANI_CAPTION, &thisWindowRect, &desktopRect);<br />
}<br />
<br />
ShowWindow(m_hWnd, SW_HIDE);<br />
<br />
NOTIFYICONDATA nid;<br />
ZeroMemory(&nid, sizeof(nid));<br />
nid.cbSize = sizeof(nid);<br />
nid.hWnd = m_hWnd;<br />
nid.uID = 0;<br />
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_INFO;<br />
nid.uCallbackMessage = WM_USER;<br />
nid.hIcon = LoadIcon(m_hInstance, MAKEINTRESOURCE(icon));<br />
nid.uTimeout = 1000;<br />
nid.dwInfoFlags = NIIF_INFO;<br />
lstrcpy(nid.szTip, "Double-Click To Maximize.");<br />
lstrcpy(nid.szInfo, "ChatApp has been minimized to the system tray.\nClick this icon to restore the application.");<br />
lstrcpy(nid.szInfoTitle, "Chat App");<br />
<br />
Shell_NotifyIcon(NIM_ADD, &nid);<br />
}
If I dont get back to you today I will definately on Monday. I'm going to make another run through the code and see if I find anything. Ill come back in the afternoon to see if you guys have any ideas. Thanks for the help!
Cliff
|
|
|
|
|
Just for the heck of it, maybe try Shell_NotifyIcon() without the
NIF_INFO flag. Same result?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No, same thing unfortunately. Maybe I can come up with something this weekend. Ill take a peak. Quiet an odd one, I know I am missing something somewhere.
Thanks again!
cliff
|
|
|
|
|
I would suggest creating a test application that does nothing but minimize itself to the icon notification area.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thats a great idea. Gunna go do it now. I'll just make a simple window with a edit box inside. We will see how it goes... I'll post tommarow!
Thanks David.
Cliff
|
|
|
|
|
Ok guys I solved the problem in my WinProc Func.
Here is what I have.
case WM_SYSCOMMAND:<br />
switch (wParam) <br />
{<br />
case SC_MINIMIZE:<br />
if (!m_bInTray)<br />
{<br />
miniMizeTray(IDI_ICON1);<br />
m_bInTray = true;<br />
}<br />
break;<br />
}<br />
DefWindowProc(m_hWnd, uMsg, wParam, lParam);<br />
if (m_bInTray == true)<br />
{<br />
ShowWindow(m_hWnd, SW_HIDE);<br />
}<br />
break;
Originally I did not have the ShowWindow command here, for kicks I added it before the DefWindowProc command, then I added it after. As soon as I added it after it worked correctly. Now due to the way I have my app setup, I am using a bool to let the app know whether or not it's in the tray, I had to setup a simple if statement for the same reason.
Any ideas on why I have to place this after the DefWindowProc command?
Cliff
-- modified at 9:43 Monday 8th October, 2007
Just to add, I figured it out making another smaller app with nothing in it accept an edit window and the same minimize functions. Thanks for that advise David! =)
Cliff
|
|
|
|
|
I just wrote a similar "tray" applicaton. At the appropriate time, I just called ShowWindow() (followed by Shell_NotifyIcon() ).
Beaon wrote: ShowWindow(m_hWnd, SW_HIDE);
That's all you need, assuming that m_hWnd is valid and the correct window handle.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yea I am running that command right after ShowWindow, makes no difference.
It sounds like I am callig the wrong HWND handle, but my main window is m_hWnd, everything else is a child of that. I just breifly double checked all my other HWND handles and found them all WS_CHILD. with m_hWnd as the parent accept the tooltips. My tooltips are children to the window in which they tip. I thought thats how I was suppose to do it but I dont think that will make a difference here.
Any thoughts?
|
|
|
|
|
Is anyone of you familiar with Anti-Grain Geometry? I just stumbled across it this week and would love to use it in my program but I can't figure out HOW to use it!
I am trying to use the C# wrapper created by the guys at CreativeDocs.Net --> http://www.creativedocs.net/
I just need someone to quickly explain how to replace gdi with agg.
Just so you know, I have exhuasted google trying to find some kind of documentation.
Any pointers would be greatly appreciated!
Richard
may your code be error free.
(okay, maybe two lines.)
|
|
|
|
|
|
Hello Friends,
I have created the New Desktop. And I am able to Switch to and from new Desktop to Default Desktop and Default Desktop to New desktop (Thnx to nitin3 ) .
But There is one Problem I am facing when I am switching to new Desktop.
I am not able to open the Task Manager in new desktop
If anybody knows how to solve the problem or why this is happening ? if anybody knows please tell me. It will be great help to me.
The other things I want to do is to personalize the ICONS and Wallpaper for new Desktop. i.e. if somebody changes the wallpaper in new desktop it should not be reflected in default desktop.
I dont know whether it is possible or not ??. If Some body have anu idea or suggation please tell me.
Thanx in Advance
|
|
|
|
|
Alright, this is not code oriented and so I'll make it brieft:
Sorry don't know how to add code in this forum yet (rather new)
A class like this:
#ifndef VXT_SIMPLE_BUTTON_SPEC<br />
#ifdef VXT_UIUTILS_DLL<br />
#define VXT_SIMPLE_BUTTON_SPEC __declspec(dllexport)<br />
#else<br />
#define VXT_SIMPLE_BUTTON_SPEC __declspec(dllimport)<br />
#endif<br />
#endif<br />
<br />
class VXT_SIMPLE_BUTTON_SPEC vxtUISimpleButton: public CGXStatic
the inherited class is FROM stingray and is now using dll interface compared to previous release like so:
#ifdef _GXDLL<br />
#ifdef _GXDLL_IMPL<br />
#define GRID_API __declspec( dllexport )<br />
#else<br />
#define GRID_API __declspec( dllimport ) <br />
#endif<br />
#else // !_GXDLL<br />
#define GRID_API<br />
#endif<br />
<br />
<br />
class CGXStatic : public CGXControl<br />
{<br />
DECLARE_CONTROL(CGXStatic)<br />
<br />
public:<br />
GRID_API CGXStatic(CGXGridCore* pGrid);<br />
<br />
GRID_API virtual CRect GetCellRect(ROWCOL nRow, ROWCOL nCol, LPRECT rectItem = NULL, const CGXStyle* pStyle = NULL);<br />
GRID_API virtual CSize AddBorders(CSize size, const CGXStyle& style);
<br />
GRID_API virtual CSize CalcSize(CDC* pDC, ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, const CGXStyle* pStandardStyle, BOOL bVert);<br />
<br />
GRID_API virtual BOOL CanFloatCell(ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, BOOL bFloatOrFlood);<br />
<br />
GRID_API virtual void Draw(CDC* pDC, CRect rect, ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, const CGXStyle* pStandardStyle);<br />
<br />
GRID_API void ImplementCellTips();<br />
};<br />
Now this returns:
error C2487: member of dll interface class may not be declared with dll interface
When using the macro:
#define DECLARE_CONTROL(class_name) \<br />
protected: \<br />
GRID_API static CGXControlClass* PASCAL _GetControlBaseClass(); \<br />
public: \<br />
static GX_DATA CGXControlClass ctrl##class_name; \<br />
GRID_API virtual CGXControlClass* GetControlClass() const; \<br />
<br />
#define IMPLEMENT_CONTROL(class_name, base_class_name) \<br />
CGXControlClass* PASCAL class_name::_GetControlBaseClass() \<br />
{ return CONTROL_CLASS(base_class_name); } \<br />
GX_DATADEF CGXControlClass class_name::ctrl##class_name = { \<br />
#class_name, &class_name::_GetControlBaseClass }; \<br />
CGXControlClass* class_name::GetControlClass() const \<br />
{ return &class_name::ctrl##class_name; } \<br />
<br />
DECLARE_CONTROL(vxtUISimpleButton)
So I tried not using dllimport ON the class but instead on every functions
Which returned this:
warning C4273 : inconsistent dll linkage
on the macro:
<br />
#define IMPLEMENT_CONTROL(class_name, base_class_name) \<br />
CGXControlClass* PASCAL class_name::_GetControlBaseClass() \<br />
{ return CONTROL_CLASS(base_class_name); } \<br />
GX_DATADEF CGXControlClass class_name::ctrl##class_name = { \<br />
#class_name, &class_name::_GetControlBaseClass }; \<br />
CGXControlClass* class_name::GetControlClass() const \<br />
{ return &class_name::ctrl##class_name; } \<br />
<br />
IMPLEMENT_CONTROL(vxtUISimpleButton, CGXStatic)
Which is present because (I think) that we defined this function:
virtual VXT_SIMPLE_BUTTON_SPEC vxtVoid Draw(CDC* pDC, CRect rect, ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, const CGXStyle* pStandardStyle);
and the stingray class defined it this way:
GRID_API virtual void Draw(CDC* pDC, CRect rect, ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, const CGXStyle* pStandardStyle);
Both are on dllImport
Any suggestion on how to "cleanly" remove the error and warning?
|
|
|
|
|
I want to know how can i get the file of '.dll' of CxImage?when i load the CxImage,i cannot find the file.Thank you!
My Email is xhj131@163.com
jane
|
|
|
|
|
Did you ask on that article?
|
|
|
|
|
Yes,i asked about the CxImage.Do you know something about it?If you do,i hope you can help me.
I want to change the format of the image from ".jpg" to ".bmp"!
Thank you
Jane131
|
|
|
|
|