|
Look up the API in MSDN and copy its prototype into your code (adding the WINAPI calling convention). So for CopyFileEx() you'd do:
typedef BOOL (WINAPI* PFN_COPYFILEEX)(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
PFN_COPYFILEEX pfnCopyFileEx;
(FARPROC&) pfnCopyFileEx = GetProcAddress ( hinst, "CopyFileExA" ); The parameter list is copied straight off the MSDN page. (I think I have the typedef right, I always forget on which side of the * the calling convention goes.)
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks for the help.
Nathan Brown
|
|
|
|
|
How I can get line number of my crash in Release. My project have some DLLs.
Georgi Georgiev.
|
|
|
|
|
I can't figure out a way to have a CListCtrl, showing checkboxes in the leftmost column, enabled but read-only. Meaning, the vertical scrollbar should still work, but the checkboxes cannot be changed.
I understand about faking it (ownerdraw, ignore clicks and keystrokes, etc), but I wonder if there is a standard way for this?
TIA,
Bernd
|
|
|
|
|
This is a confusing issue for me. I think its very relevant to note that this is a dynamically created combobox in a CtoolBar derived class..
I am dynamically doing a Create() to make a combobox in a toolbar. I want to trigger a certain function when I dblclick on a list item of the combobox. How do I set this up? What all do I need to add to my code and where? I gave the toolbar spaceholder button an Id of ID_COMBO1 where its supposed to put in the combobox. In the Class wizard this ID has the COMMAND available but the OnCommand function it made doesnt tell me which item in the list I clicked> Actually what exactly is the COMMAND thing here? In a button when you press it , the commnad handler runs. WHen does the commnad handler run for a combobox? I also guess that you can trap the CBN_DBLCLK message but dont know how to do that . If I can run a handler when this message is trapped, the function that runs can check on the index of the item clicked and do something specifically index-related. SO the index must be passed into the handler. Which class will trap this message and how do I do it in code? In the class wizard I didnt see CBN_DBLCLK. (I am sorry I might be looking in the wrong places... )
In one sample I saw they had : BOOL CToolBarWithCombo::OnCommand(WPARAM wParam, LPARAM lParam) for a toolbar derived from CToolbar. I dont see how to add this function through the class wizard. iN the code it says:
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
so its been done through CW . But how ? Theres no ID_TOOLBAR that I can create a Command handler for...
How do you add a COMMAND handler for a toolbar and after d oing so, how do you set it up to tell you that item number n in the list (ot text "abc" in the list) was pressed in the combobox?
My goal is to make a specific function run when i press an item in the list of my combobox, which is created dynamically, and embedded in a CTOolBAr class .
Appreciate your help,
ns
|
|
|
|
|
If you look up WM_COMMAND in MSDN you will see what the two parameters are used for. The LPARAM parameter will contain the HWND of the control that generated the message. The high word of the WPARAM parameter will contain the message code, in this case CBN_DBLCLK . And the low word of the WPARAM parameter will contain the controls ID, in this case ID_COMBO1 .
So in order to handle a message from the toolbar (or controls in the toolbar) I would override the OnCommand() function in the CMainFrame class (parent window of the toolbar).
BOOL CMainFrame::OnCommand(WPARAM wp, LPARAM lp)
{
HWND ctrlHWND = (HWND)lp;
int ctrlID = LOWORD(wp);
int message = HIWORD(wp);
if (ctrlID == ID_COMBO1)
{
if (message == CBN_DBLCLK)
{
}
}
}
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
So I still dont know which item in the list was clicked that issued this message .
(Oh! I think I can get it from the GetCurSel of the control once I confirm it was the combo box that was clicked..:-O) THere is no parameter that sends in the index or text of the clicked item.....unless I missed something which I desperately hope I didnt..... (I KNOW I have to learn a lot more)
Thank you for explaining. FRom the MSDN when I typed in WM_COMMAND: they have a callback which goes as:
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
WM_COMMAND, // the message to send
WPARAM wParam, // notification code and identifier
LPARAM lParam // handle to control (HWND)
);
and I havent made the connection between OnCommand and this windowProc. I dont really know what happens in the background so even though I am using MFC, apparently callback stuff is still operational (I feel like I am making a really stupid statement here!). Also most of the time I've seen ONCommand() like the one the classwizard creates when you press a button, doesnt have any parameters. I did note that the mainframe OnCommmand has parameters wParam, lParam which somehow you have deduced is related to the wParam lParam from the callback.
Also , how did the sample code from CP have a classwizard created handler for a toolbar OnCommand? THeres no ID_TOOLBAR, though theres a mainframe class, and a ID_COMBOBOX. Both the latter two allow me to add the COMMAND handler via the CW. But how to add a command handler for a CToolBar using the CW? That has the same prototype with lParam and wPAram...
I saw this in a CP article on comboboxes in toolbars.
Thank you again.
|
|
|
|
|
|
Thanks for the links! THe call stack window is something new for me. I will explore it! I really do appreciate your patience and input!
|
|
|
|
|
First I want to populate a combobox with data from a recordset (I imagine I can store the strings in an array). Next I want a certain item (specified by name ) to be selected - I think that will make it show up in the editbox part. Then if I run down my list and click on another item, I want a certain function to run..
I checked the CComboBox class and its got index based function SetCUrSEl, not textstring based .
Is InitStorage necessary? Is this doing memory allocation like "new" does?
Aaargh! I wish I could get all the info clearly from MSDN.....
Thanks
Appreciate your help,
ns
|
|
|
|
|
Yeah, sure you read the docs...
AddString()?
FindStringExact()?
SetCurSel()?
GetCurSel()?
And for a wild guess, trapping ON_CBN_SELCHANG???
And you know what? IT IS IN THE DAMN DOCS.
(Sorry for being such an a**hole but lazy people are just driving me nuts)
"Well I'm just a hard working corporate slave, my mind should hate what my body does crave.
Well I'm just a humble corporate slave, driving myself into a corporate grave"
Corporate Slave, SNOG
|
|
|
|
|
I think what he meant is that the MSDN can be hard to understand sometimes...Unbelievably resourceful but the writer(s) often start talking about something and you understand what you have to put into your program but by then end of the sentence you have changed your mind because what you just read could mean one thing or another depending on how you look at it. At least in my opinion,
|
|
|
|
|
Basic design info:
Dialgo app, main window always up and one secondary dialog window can be broght up one at a time from the main window. Each window has a timer that updates based on data read from another computer. Most of the controls are buttons based on CButtonST. I use the m_MouseOnButton in the control to turn it on or off, thus this enables me to set the color and text on the button (is there a better way to do this????)
Problem: After this program runs for awhile it stops drawing the CButtonST subclassed controls and some of the drop downs start displaying a "6" instead of the down arrow. All the static and straight Visual Studios controls don't seem to have this problem (they are alway visable).
I've had this problem for quite some time now and have tried just about everything to make it go away. I thought that I was on to something when I slowed the timers and the problem took much longer to happen. So I figured that I was telling windows to draw too much. To many WM_PAINT messages, is this possible? Do VS controls have priority over subclassed controls? Does each item that has changed create a WM_PAINT message? Is this bad? Is there a better way?
Thinking along these lines I went into the code for every page and made it so that the controls would only be changed if the data received from the other computer had changed, thus it stopped drawing every cycle of the timer. This seem to help as now it really takes a long time for the problem to show up, but when it does it doesn't go away until I re-start the application.
This is my first VS MFC application and I've done it all with the help of this forum. So there is a good chance that maybe I overlooked something or am doing something that I shouldn't.
Any help would be much appriciated!!!!
Thanks!
|
|
|
|
|
It sounds to me like you are using up GDI resources and not freeing them. Have you done a Debug build and checked for memory leaks when your app closes?
Also try the www.GlowCode.com demo, which does a good job of reporting leaks. There are probably other apps around which help you track leaks as well.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
I have been using the debugger and checked for memory leaks...haven't found any. I've also been watching the memory usage and CPU Time in the Windows Task Manager and the memory doesn't seem to change much and it doesn't just keep building...it uses some then it frees it when it's done.
Thanks I'm going to give the GlowCode a shot.
If I find the problem I'll let you all know...
Thanks!
|
|
|
|
|
DC and HANDLE leaks etc. won't show up as memory leaks, so you need other tools for these types of problems. I hope Glowcode helps you find the problem.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Try opening Task Manager and selecting the Processes tab. Open the View menu and choose 'Select Columns...'. Check the 'GDI objects' item. This will display a column for the number of GDI objects your application is using.
Software Zen: delete this;
|
|
|
|
|
I went and checked the GDI objects on the task manager and found that when I close the secondary window that I just opened the GDI object count doesn't decrease by the amount that was taken and will continue to grow as I open and close the page.
When I close the page I'm doing:
DestroyWindow();
PostNcDestroy();
My objects on the page are created using:
CButtonST Satus_RX;
CButtonST Satus_DUP;
CButtonST Satus_16F;
CButtonST Satus_16R;
etc.....
Then in InitDialog() I subclass them using:
Satus_RX.SubclassDlgItem(IDC_ALQ122_RX,this);
Satus_DUP.SubclassDlgItem(IDC_ALQ122_DUP,this);
Satus_16F.SubclassDlgItem(IDC_ALQ122_16F,this);
Satus_16R.SubclassDlgItem(IDC_ALQ122_16R,this);
Thus I'm under the impression that these will be delete with the window, am I wrong? What should I do now?
Also, I was looking at CButtonST and it appears that if m_MouseOnButton = 1 then it will re-draw the item every time. I set the button to 1 as this is how I display info from the other computer. example: if the other computer is ON then I set the mouse button to 1 so that its text displays "Running" and the Color is Green. If the other computer is off then the button is set to 0 and displays "OFFLINE" and the button is colored Red. Is this the wrong way to handle this?
Thanks for all the help guys. I've tried to download the GlowCode but haven't been able to yet....
|
|
|
|
|
You shouldn't be calling PostNcDestroy() yourself; it's called by the framework. Child windows are deleted by Windows when their parent is deleted.
I haven't used CButtonST . You might post/email a question to the author of the article it came from.
Software Zen: delete this;
|
|
|
|
|
Please let me know if you have any questions about using GlowCode, or about downloading an evaluation from www.glowcode.com/eval.htm.
Barbara Shafer
VP, Product Management
Electric Software, Inc. ~ developer of GlowCode
www.glowcode.com
|
|
|
|
|
In
int Box::AddString(LPCTSTR str)
{
if( _tcslen(str) == 0 )
why the tcslen? WHy not strlen? If I wanted to use wcslen (says its for wide characters) what would my argument look like?
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
_tcslen
is the generic form of the command. It works for ANSI and UNICODE. If you compile for UNICODE it uses the wide character form of the strlen function, and for ANSI the strlen form.
So basically it future proofs your application. Its good practice to get into now.
Roger Allen
Sonork 100.10016
WHats brown and sticky?
A stick or some smelly stuff!
|
|
|
|
|
Good to know. MAny thanks. I did look in the MSDN but it was obtuse...
Appreciate your help,
ns
|
|
|
|
|
I read about _T in MSDN but am not clear :
It says _T is ignored in rgComboBox[index]->SetWindowText(_T("")); so why do it at all? Then when is it necessary to use L("")...I've seen that as well...
Appreciate your help,
ns
|
|
|
|
|
Basically, every (almost) type which starts with T , functions which start with _t are ANSI/UNICODE related.
#ifdef UNICODE
typedef wchar_t TCHAR;
#else
typedef char TCHAR;
#endif
typedef TCHAR* LPTSTR;
typedef const TCHAR* LPCTSTR;
size_t _tcslen(LPCTSTR);
LPTSTR _tcsdup(LPCTSTR);
You get the picture...
--
Eventhough the forrest is full of trees, there's still no tree between the trees.
|
|
|
|