|
you can get yourself a timer and call InvalidateRect based on the timer u chose, u can use as elapse time 33 millisecs so u get the rate u want.
Better approaches to this is to override the Run function of ur application and call Render there when u have no messages to handle with the elapsed time u want
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I have question about those game trainers for games like Red Alert, Diablo, etc., where it enables you to cheat in the game, such as freezing your money, etc.
So how can i go about finding the memory address of the those variables or values i wish to modifiy?
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
|
|
Thanks... I'll see if i can understand those assembly stuff...;)
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
|
Hi.
Is there an object that is part of each item (row) in a CListCtrl that can be used to store arbitrary data or a pointer to them? For example, give there a CListCtrl with two columns. Both columns contain texts; however, I want to store data or pointer to data that correspond to the items in CListCtrl.
I have considered other solutions include an independent STL contains such as a vector that will update as the user makes changes to the CListCtrl. There is a performance reduction for removal. Thus, I that is the last resort.
Thanks,
Kuphryn
|
|
|
|
|
Each item has an LPARAM, which is pointer-sized so you can store a pointer there. If you need data for each column, you'll need to keep a struct or vector or other collection, and hold its address in the LPARAM
--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
|
|
|
|
|
|
Hello all.
Recently I've encountered the weirdest problem.
In every project i create, all the DDV error messages and all the common messages (i.e. in an SDI/MDI app. instead of seeing "Untitled" at the caption I see some garbage in german), i get in german, or some other language, and not in english.
I've checked all the project resource files and made sure that the language is English u.s., and even under the resource tab in the project settings i've made sure that the language is english u.s., but still, all the messages are in difference language (even in CFileDialog, instead of Open, and All files for example, i get weird language).
Any ideas ?
Help will be appreciated...
|
|
|
|
|
I had a similar problem recently on NT4, my keyboard changed to German layout from UK English. German had been set as an "input locale", but I was using my default, English, my only "cure" was a reboot I assumed something had screwed up the PC.
The obvious question, if you run the code onto another PC what happens
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Two questions - the shorter one first.
When a compiler informs you
warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
just how much of a performance hit are we talking about?
Second (the biggie)
In the following code excerpt (which is located in the OnDraw method of an MDI app)
// Fill the client area with black
pDC->FillRect(&rcScreen, &backgroundBrush);
// preserve the aspect ratio
CRect NewPictRect = m_pDIBBitmap->CalcAspectRatio(Rect, TRUE);
// get the bitmap
BITMAP bm;
GetObject(hBmp, sizeof(BITMAP), &bm);
// prepare the bitmapinfo structure
BITMAPINFO bmInfo;
memset(&bmInfo.bmiHeader, 0, sizeof(BITMAPINFOHEADER));
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth = m_pDIBBitmap->GetBitmapWidth(hBmp);
bmInfo.bmiHeader.biHeight = m_pDIBBitmap->GetBitmapHeight(hBmp);
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biBitCount = 24;
////////////////****CUT HERE****////////////////////
// creates the memory dc
HDC TmpDC = CreateCompatibleDC(NULL);
// create bitmap and select into the mem dc
BYTE *pbase;
HBITMAP TmpBmp = CreateDIBSection(TmpDC, &bmInfo, DIB_RGB_COLORS, (void**)&pbase, 0, 0);
// select the object into the current dc
HGDIOBJ TmpObj = SelectObject(TmpDC, TmpBmp); // TmpDC is the dc to draw lines, text, etc...
// draw the background
HDC dcBmp = CreateCompatibleDC(TmpDC);
SelectObject(dcBmp, hBmp);
BitBlt(TmpDC, 0, 0, m_pDIBBitmap->GetBitmapWidth(hBmp), m_pDIBBitmap->GetBitmapHeight(hBmp),
dcBmp, 0, 0, SRCCOPY); // Destination DC first, then source DC
DeleteDC(dcBmp);
// Clean up
DeleteObject(hBmp);
hBmp = TmpBmp;
SelectObject(TmpDC, TmpObj);
DeleteDC(TmpDC);
////////////////*****END CUT HERE*****//////////
m_pDIBBitmap->DrawBitmap(pDC, hBmp, pPal, NewPictRect, Rect);
If I remove the code between the //////////***CUT HERE***///
bits, there is a significant decrease in redrawing speed. Note, however, that the call to DrawBitmap (m_pDIBBitmap->DrawBitmap(pDC, hBmp, pPal, NewPictRect, Rect) ALSO draws the bitmap, independent of the code between the CUTS...
Thus, if I remove the code between the cuts, the bitmap draws fine, but SLOW. If I keep the code the bitmap draws fine but FAST. Can't say I have figured out what is going on here. I seemed to have stumbled upon it inadvertently.
Any input appreciated...
|
|
|
|
|
John Theal wrote:
warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
just how much of a performance hit are we talking about?
I can't imagine much. If you were to do it in C it would be something like bool bWha = !(!nWha); . As with everything, if performance is an issue, then profile your code and find the bottlenecks; otherwise don't worry about it.
John Theal wrote:
Second
Looks like you're trying to do some double buffering here? You can speed it up a lot by NOT creating the back buffer each time you draw; just (re)create it whenever the size changes, and re-use it otherwise. Also, you can't delete a bitmap while it's selected in a DC.
---
Shog9
The siren sings a lonely song - of all the wants and hungers
The lust of love a brute desire - the ledge of life goes under
|
|
|
|
|
I am doing some double-buffering in OnDraw(). There is also some double-buffering going on in DrawBitmap(). However, I have accidentally noticed that Blitting to the TmpDC, then releasing the handle (hBmp) and finally, setting the handle (hBmp) to TmpDC speeds things up incredibly for some reason.
It is rather odd. I suppose I could not re-create the back-buffer each time, but the app is such that the user can drag the frame of the MDI window and enlarge/decrease the size of the bmp at any time - so it sort of needs to happen that way. Anyways, the speed really isn't a problem at this point. I would just like to know *why* this is occuring...
|
|
|
|
|
Ah, sorry - i misunderstood. I'm not sure why this would be faster, unless the original bitmap is in a different format than the screen and the conversion is performed slowly by DrawBitmap().
---
Shog9
The siren sings a lonely song - of all the wants and hungers
The lust of love a brute desire - the ledge of life goes under
|
|
|
|
|
Hello I am trying to use the API function CopyFileEx() however I want my application to run on Windows 95 and this function is not implemented on that system
I cannot even include the function in an IF statement and get the application to run on 95. Something about the kernel32.dll does not export the function.
Is there any easy way to take care of this? Or is the only way to manually do the LoadLibrary, GetProcAddress, AND define a custom variable type? The last one is the worst.
I am really hoping for some answers that I could expand to all functions that I want to use from the newer Windows versions.
Thanks
Nathan Brown
|
|
|
|
|
GetProcAddress is about the only way you can do it. Also, since we are talking about KERNEL32.DLL, a GetModuleHandle will be good enough. You won't have to worry about using FreeLibrary (???) with GetModuleHandle.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
What about the requirement of defining a custom variable type? Is there any way to use the fact that it is already defined in the SDK?
I tried using something like this:
CopyFileExA ProcAdd;
ProcAdd = (CopyFileExA)GetProcAddress(hinstLib, _T("CopyFileEx")); But it didn't work.
Nathan Brown
|
|
|
|
|
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!
|
|
|
|
|