|
Sorry, I wasn't aware of this. I apologize.
-- narada
|
|
|
|
|
carrie wrote:
Its not easy to tell from your code because of the way the site skews the formatting
If people only could learn not to use TABs in their source,it would look nicer.
Gisle V.
"If you feel paranoid it doesn't mean they're not after you" -- Woody Allen
|
|
|
|
|
Hi,
I have a audio player that is skinned. There are 4 seperate regions (different states in the player). I create these regions before hand on program start up. My problem is that when I try to set a region that has already been used before the SetWindowRgn function fails (I'm guessing because windows deleted it or something)
I want to avoid creating the region on the fly because it takes a second or so to create the region from the bitmaps that I use for skinning.
Is there anyway to stop windows from deleteting the region after you set the window region to a different one.
Thanks
|
|
|
|
|
Ceri wrote:
Is there anyway to stop windows from deleteting the region after you set the window region to a different one
No. MSDN states:
After a successful call to SetWindowRgn, the operating system owns the region specified by the region handle hRgn. The operating system does not make a copy of the region, so do not make any further function calls with this region handle, and do not close this region handle
But you can use CRgn::CopyRgn() to make a local copy of your region, before you feed it to the API.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Is the CopyRgn function of the CRgn class fast enough so that it does not show a delay.
|
|
|
|
|
Sorry, I have no idea.
Just remember to tell here if you find out
Good luck with you project!
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
It should be. Anyway, i think this API must be the fastest:
DWORD dw;
RGNDATA *lp;
HRGN hRgnCopy;
dw=::GetRegionData(hRgn, sizeof(RGNDATA), NULL);
lp=(RGNDATA *)(new char[dw]);
hRgnCopy=::ExtCreateRegion(NULL, dw, lp);
delete lp;
rechi
|
|
|
|
|
Ummm. Maybe you can copy the region (CopyRgn ) before passing it on to the windows with SetWindowRgn so that you have always a fresh copy to work with.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello,
maybe this is a little off-topic, but i don't know where to post this problem - sorry. I need to determine if my source-code is compiled by vc60 or .net, because i have to include different header-files depending on the compiler-version. I want to do it in a way like this :
#ifdef _VC60
#include <..\src\afximpl.h>
#else
#include <..\src\mfc\afximpl.h>
#endif
I think that there must exist a global constant or variable that describes the compiler-version. But what is the name of this constant or variable (it's not _VC60 ).
Best regards
tabor25
|
|
|
|
|
You can get the compiler version with _MSC_VER. Look into the online help for the possible values.
However from your example I guess that you really want to use _MFC_VER which gives you the MFC version (>= 0x0700 for MFC 7 or higher).
Oliver
|
|
|
|
|
Thank you very much, Oliver. I will use the online-help to figure out the rest.
Best regards
tabor25
|
|
|
|
|
Hi,
can anyone help me with this prob ??? I am at a total lost
I have several pointers (using them as matrix) and i have always allocate mem to them using the "new" operator. However i encounter a strange problem with one of them (temp). Whenever my program trys to access the pointer 'temp' up to a location, it would generate an "First-chance exception: 0xC00000005: Access violation" error.
an eg of the code is like this:
double * temp
temp = new double (5000);
for (i = 0; i < 5000; i ++)
{
temp[i] = x*y;
}
I use breakpoints and see that the index of temp from 1 to 2577 is valid. However when i > 2578 all the values are invalid ("CXX0030: Error: expression cannot be evaluated") and hence causing my program to hit the ""First-chance exception: 0xC00000005: Access violation" error. This seems so strange to me and i am at a lost of what to do......
Can anyone tell me why is it so ?? and how can i solve this problem??
Thank you very much for your kind attention !!
|
|
|
|
|
Must be:
temp = new double [ 5000] ;
rechi
|
|
|
|
|
Hi rechi,
Really thanx a lot ... I guess i made a silly typo without realizing !! You save my day
bk
|
|
|
|
|
Hello everybody,
My task is to interrupt a job (click on a button) that takes a lot of time for execution (a kind of endless loop). This code is in a DLL.
I tried different methods without success.
If the code is executed in the same thread, I can solve this problem with the ::PeekMessage() function.
Is the DLL executed in a different thread?
Can you help me?
Thanks,
Gelu
|
|
|
|
|
In principle, DLL code is executed in the same thread as the EXE that invokes it, unless the DLL launches a secoondary thread on purpose.
Anyway, I'm curious about how you plan to terminate the llop using PeekMessage . Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Obviously, when I work in a executable my code seems like this:
fct()
{
.... init loop ...
MSG msg;
while(!(::PeekMessage(&msg, GetDlgItem(IDC_STOP)->m_hWnd, 0, 0, PM_NOREMOVE))
{
...... do a step ...
}
}
where IDC_STOP is a button.
If I put the same code in a DLL
fct()
{
.... init loop ...
MSG msg;
while(!(::PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE))
{
...... do a step ...
}
}
The GUI freezes and I have to use the task manager to kill the task
Thanks,
Gelu
|
|
|
|
|
Hi,
First create a new thread for your endless loop function. Then the first line of the thread execute the following
[code]
PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE)
[/code]
This will force the OS to create a non windowed message loop. Inside your loop you can the use PeekMessage or GetMessage to receive messages for that thread. Obviously the hWnd member of the MSG struct will contain NULL because is has no window.
To post a message to the thread message loop use PostThreadMessage. This will fail if you haven't created the message loop at the start of the thread
Hope this helps
Ceri
|
|
|
|
|
Hi Ceri,
My experience on creating threads in Windows system is very limited. Can you recommend me some code?
Thanks,
Gelu
|
|
|
|
|
Try this
[code]
#include "stdafx.h"
#define CUSTOMSTOPMSG WM_USER + 1
DWORD WINAPI ThreadProc(LPVOID lpParameter);
void StartThread();
void StopThread();
//the thread ID. Must give this ID to PostThreadMessage
DWORD dwThreadID = 0;
//this function is the thread function - contains the infine loop
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
MSG msg;
int iRetVal = 1;
PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); //forces creation of non windowed message loop
while(!(PeekMessage(&msg, NULL, CUSTOMSTOPMSG, CUSTOMSTOPMSG, PM_REMOVE)))
{
//....do processing here
};
//.... do clean up here
return(iRetVal);
}
//execute this function from your standard thread
void StartThread()
{
HANDLE hThread;
//you can use this to pass a parameter to your thread
//(usualy a pointer to a struct or some other kind of user data)
LPVOID pParam = NULL;
hThread = CreateThread(NULL,0,ThreadProc,pParam,0,&dwThreadID);
}
void StopThread()
{
//obviously wParam and lParam in the PostThreadMessage could be some value also
if(dwThreadID)
PostThreadMessage(dwThreadID,CUSTOMSTOPMSG,0,0);
}
[/code]
Call StartThread when you want to initialize the loop and StopThred when you want to stop (I guess you would use your button for this)
Let me know how you get on
|
|
|
|
|
Many thanks Ceri. It works perfectly.
Gelu
|
|
|
|
|
|
I'd like to create a control (a ComboBox) and position it at the bottom of a window. Thus I need to know the height of this control before I create it.
If I just measure it on this PC and code it as a const, then it will look ugly if someone has a bigger font or s.th else is changed.
Is there any way to get the standard size of such a control without creating it first ? (s.th. like GetSystemMetrics for controls)
|
|
|
|
|
I couldn't find any function equivalent to GetSystemMetrics for combo boxes, but I would try this technique:
1. Create a temporary combo box without the WS_VISIBLE flag, so that it's invisible.
2. Retrieve its height. GetWindowRect should do it.
3. Destroy it.
Regards,
Alvaro
All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain
|
|
|
|
|
Works just like it should
thank you.
|
|
|
|