|
well if i showed my working code it would kinda fill up most of this forum and posting a lot of code in here tends to be tedious
as far as the questions go
as far as knowing im not supposed to delete regions ive used in setWindowRgn, no i did not know but i do know, which kinda begs the question how to you resize a region without destroying it or setting a new windowrgn.
again as far as identical local variables i didnt actually think it would matter in this trial run but also again i was wrong lol
so begs the question given my own GUI and region how would i resize it lol
The regions used are below along with the definitions and most of the skining stuff
at the top with the beloved variables I have
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002
#define g_ColourKey 0xFF00FF // 255,0,255(pink) in hex RGB
#define WS_EX_LAYERED 0x00080000
#define IDB_CLOSEWINDOW 1000
typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
lpfnSetLayeredWindowAttributes SetLayeredWindowAttributes;
int nWidth = 506;
int nHeight = 376;
BOOL mDown = FALSE;
POINT AnchorPoint;
the initial regions are create at the top of WndProc and are used in WM_CREATE
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
HRGN hRegion1 = CreateRectRgn(0, 0, nWidth, nHeight);
HRGN hRegion2 = CreateRectRgn(0, 0, nWidth, nHeight);
switch(Msg)
{
case WM_CREATE:
g_Hwnd = hWnd;
dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
SetWindowLong(hWnd, GWL_STYLE, dwStyle);
CombineRgn(hRegion1, hRegion1, hRegion2, RGN_OR);
SetWindowRgn(hWnd, hRegion1, true);
SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hWnd, g_ColourKey, 0, LWA_COLORKEY);
m_hCloseButton = CreateWindow("BUTTON",
"x",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_CENTER | BS_FLAT,
nWidth-28, (nHeight-nHeight+10), 20, 20,
hWnd,
(HMENU)IDB_CLOSEWINDOW,
hInst,
NULL);
WM_PAINT calls a function called skin() which is below
BOOL Skin() {
HBITMAP hSkinBmp = LoadBitmap(hInst,MAKEINTRESOURCE(IDB_MAIN));
if (!hSkinBmp) return -1;
HDC dcSkin = CreateCompatibleDC(0);
HBITMAP hOldBmp = (HBITMAP)SelectObject(dcSkin, hSkinBmp);
PAINTSTRUCT ps;
BeginPaint(g_Hwnd,&ps);
BitBlt(ps.hdc, 0, 0, nWidth, nHeight, dcSkin, 0,0, SRCCOPY);
EndPaint(g_Hwnd,&ps);
return 0;
}
and as far as the mouse move well you have all that and i may aswel delete most of it and start again lol
WinMain is just the standard create you own Win32 API window
so any help would be had lol as you can tell im a n00b trying to learn API and not having too much success
|
|
|
|
|
Okay, I've had a look at your code Sarriss, and the one thing that strikes me more than anything is the approach you've taken.
Typically, whenever a resizeable box with rounded corners is drawn, it is drawn using 9 images - top left corner, top middle, top right corner, right middle, middle-middle, right-middle, bot left corner, bot middle, bot right corner.
Doing so means that the corner pieces are always drawn at the correct scale and that the window is sized by stretching all pieces except the corner images.
In your case, it'll be not quite that simple since the bar across the top of the window isn't of uniform height. You may need 5 images to cover the top - the two corners, the low part, the high part and the transition between the two. To make the window wider, you'd just stretch the high part and/or the low part, while drawing the corners and the transition at 1:1 scale.
If you've not seen it, you may like to take look at this.[^]
|
|
|
|
|
Thnx, will take a look at the picture thing i knew kind of that i would need a lot of pictures was more trying to get the window to resize first and making sure i had the resize of the window but i will take a look at the link you gave me, might give me more ideas lol
and also given that i have two levels at the top pic couldnt i just have a bigger corner piece in the corner and then have the otherone plus the pink bit that isnt showing.
also how do you scale/stretch the pictures :S been looking for that for like ages
|
|
|
|
|
Pleasure. Yeah, the link I left is quite a good example of this type of work.
Well worth a close read.
Sarriss wrote: and also given that i have two levels at the top pic couldnt i just have a bigger corner piece in the corner and then have the otherone plus the pink bit that isnt showing.
Sorry, I don't quite follow you here. Could you put it another way?
As for scaling/stretching the picture, have a look at the docs for StretchBlt , that should do what you need.
|
|
|
|
|
enhzflep wrote: In your case, it'll be not quite that simple since the bar across the top of the window isn't of uniform height. You may need 5 images to cover the top - the two corners, the low part, the high part and the transition between the two.
couldnt i just use one pic in the top right corner even if it isnt uniform height
|
|
|
|
|
Oh - yeah sure. That'd be fine. A picture can be worth a 1000 words, so I've sent you a bunch.
I've sent you an email that shows how I'd chop the picture up.
|
|
|
|
|
wow, lol they are like mega small had to zoom in to see them will the stretchblt thing work well with that kinda stuff then???
|
|
|
|
|
Hehe - from over 500kb of image down to around 20kb - nice huh?
Yeah, stretchblt should work fine with them. You only need to stretch the toplow, tophigh, left, right and bottom images - that's why these are all only 1 pixel wide or high. If for whatever reason StretchBlt doesn't work, you can just draw a piece repeatedly until you have a border of the appropriate length.
Not sure which approach the article I linked you to uses, but it'd be one of the two.
|
|
|
|
|
havent finished going through the source code of the article but i loaded the toplow bit into a region and used the stretchblt and it worked beautifully now just have to create a function to put them all together lol, will take me a while im sure heh, thank you very much for your help, couldnt have asked for better
|
|
|
|
|
I would do something like this...
case WM_LBUTTONDOWN:
if(
{
SetCapture(hWnd);
mResize = TRUE;
}
break;
case WM_LBUTTONUP:
{
<code>if (mResize)
{</code>
ReleaseCapture();
mResize = FALSE;
<code>}</code>
}
break;
Beyond that, if its not resizing properly, you'll need
to debug your resizing code
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello, friends~
I have some questions about the MFC programming.
I use the Visual studio 2005 and use Multi-byte-code.
I execute this code..(this is in CView)
///////////////////////////////////////////////////////////////////////////////////
void CRETURN1View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
int nCharIndex;
nCharIndex = m_strOutText.GetLength();
if(nChar == VK_BACK)
{
m_strOutText.Delete(nCharIndex-1, 1);
}
else
{
m_strOutText += nChar;
}
Invalidate();
CView::OnChar(nChar, nRepCnt, nFlags);
}
//////////////////////////////////////////////////////////////////////////////
this error is occur..
// error C2593: 'operator +=' is ambiguous //
I don't know why this error is occur
ps. m_strOutText is CString data type.
plz tell me what is problem...
|
|
|
|
|
In VC6.0 its possible. But in VS2005 rules are a bit more strict and you've to convert the UINT to TCHAR since in CString += doesn't expects a UINT to be added to it.
Well, for making it compilable, just cast to TCHAR as follows,
m_strOutText += (TCHAR)nChar;
m_strOutText += static_cast<tchar>( nChar );</tchar>
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
FR2ESOD wrote: // error C2593: 'operator +=' is ambiguous //
m_strOutText += nChar;
The compiler is not sure what to make of this.
Bram van Kampen
|
|
|
|
|
Hi,
I have a DialogBox with a Single line edittext control
Whenever I enter a number and use GetDlgItemText reterive the data
Nulls get inserted between each character/byte
e.g. if I enter 123456 in the Editext it appears in Memory
as 31 00 32 00 33 00 34 00 35 00 36
is there maybe a ES_ style I should add to the resource file when
Creating the edit control or Maybe sending a message to the edit
control to Format the text ???
thankx
|
|
|
|
|
If you're doing a UNICODE build (i.e. the default with Visual Studio 2003 and above) then there's nothing strange you're getting a UNICODE string.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Just changed The Visual Studio Build "Character Set" in the
Configuration Properties->General->Project Defaults->character Set to "Not Set" from Unicode
and it worked thankx
|
|
|
|
|
Hi,
How to set null to 2*2 static array in c++ after declaration.
I tried like this
ULONGLONG Array[2][2];
memset(Array,0x0,sizeof(ULONGLONG)*2*2);
What is wrong with this?
|
|
|
|
|
You could initialize it like this -
ULONGLONG Array[2][2] = { {0,0}, {0,0}};
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Or simply:
ULONGLONG Array[2][2] = {0};
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
MPTP wrote: What is wrong with this?
It is not wrong, Anyway Jijo rai's one [^] is much more better.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All,
I'm a bit perplexed at the behavior of the ShellExecute function. I have two apps. One is called Test.exe, and the other is called suicide.exe. It's pretty obvious what suicide.exe does: it suicides. It deletes itself and Test.exe. When I run suicide.exe manually (dblclicking it), it works fine. Test.exe and Suicide.exe are gone.
Unfortunately, when I try to use a ShellExecute from Test.exe to run Suicide.exe...well, the results are totally disastrous. In the WinMain() function in Suicide.exe, I put a Sleep(2000) followed by DeleteFile("Test.exe"). In Test.exe, after I call ShellExecute(...), I immediately call CDialog::OnClose(). So supposedly, after the ShellExecute function is run, Suicide.exe is supposed to start, and Test.exe is supposed to close itself, then after 2 seconds Suicide.exe kills both files.
That's what should happen theoretically. What is actually happening is that Suicide.exe succeeds in killing itself, but even after the 2 second delay Test.exe is still running. So when it tries to kill Test.exe, it obviously fails. And then, for some unknown reason, Test.exe keeps on starting copies of Suicide.exe forever, until I terminate Test.exe. After I do terminate Test.exe, all the spawned Suicide.exe's are gone, and the two files are also killed.
My two questions: Why does this behavior occur instead of what should occur theoretically? And could anyone help me resolve this?
Thanks in advance.
Btw, it took me quite a lot of thinking to explain this properly. If any part of this is unclear just ask and I'll try my best to explain.
|
|
|
|
|
hmm
You are trying to delete a running exe ? I think the OS may object against that.
Bram van Kampen
|
|
|
|
|
No, I'm not trying to kill a running exe. As I mentioned, Test.exe is supposed to close, and after a 2 second delay Suicide.exe is supposed to delete Test.exe and itself.
My question is why Test.exe doesn't close even when I call TerminateProcess right after I run Suicide.exe
|
|
|
|
|
well, i think you should try to move it into recycler directory.
|
|
|
|
|