|
Hi all,
how can i change the color of the Title bar of the window in SDI aplication.
varun
|
|
|
|
|
See here[^] and here[^].
Also, see here[^].
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Hamid. wrote: Owner Drawn Menu with Icons, Titles and Shading[^].
What are you linking him to? He's asking how he could color the Title bar[^].
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hey I saw your reply and I guess maybe he like to customize its menu,but why give me this link?
|
|
|
|
|
may be he tried "titles" in the article search, u can check this now.
It is like search bot
|
|
|
|
|
dear all
how to use image in c++, including build CDib class and load image, display, anyone has such code under vc++ 60 IDE, it is better to use in one dialog box. thanks a lot
Li Zhiyuan
|
|
|
|
|
Whats your problem can you use of CDib or you have other problem?
|
|
|
|
|
What are you having trouble with?
With the CImage class you can load an image in 1 line of code.
You can render an image with one or two lines of code.
What is CDib?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
Here are two conflicting documents from MSDN. About whether linker will modify code generated by compiler. I quote both of them here.
Document (1) mentioned linker can not modify any code generated by compiler, but document (2) mentioned linker will replace address code generated by compiler during fixup process.
Which one is correct?
1.
http://blogs.msdn.com/oldnewthing/archive/2006/07/21/673830.aspx
--------------------
But the linker can't rewrite the code generated by the compiler.
--------------------
2.
http://www.microsoft.com/msj/0797/hood0797.aspx
--------------------
Consider a call to a function named Foo in C++:
//...
Foo();
//...
The exact bytes emitted from a 32-bit C++ compiler will be this:
E8 00 00 00 00
The 0xE8 is the CALL instruction opcode. The next DWORD should contain the offset to the Foo function (relative to the CALL instruction). It's pretty clear that Foo probably isn't zero bytes away from the CALL instruction. Simply put, this code wouldn't work as expected if you were to execute it. The code is broken, and needs to be fixed up. In the above example, the linker needs to replace the DWORD following the CALL opcode with the correct address of Foo.
--------------------
thanks in advance,
George
|
|
|
|
|
George_George wrote: Which one is correct?
The non-wrong one.
The linker does not modifiy your code. Moving code around in memory (i.e, rebasing) does not change the code itself. Both statements are correct.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks DavidCrow,
You mean both of them are correct? But they are of different options, the point of the first one means linker can not modify the code produced by compiler, but the 2nd one means linker modifies the code produced by compiler.
regards,
George
|
|
|
|
|
George_George wrote: You mean both of them are correct?
Is that what you inferred from what I said? Just take the red pill and watch out for stray rabbits.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
The second is correct.
Steve
|
|
|
|
|
Thanks Stephen,
Your confirmation makes me more confident.
regards,
George
|
|
|
|
|
I have done the basics in creating a simple GUI framework. Set the WNDCLASSEX with lpfnWndProc pointing to a static member function of my base window class. Calling CreateWindowEx with the appropriate parameters returns a valid HWND. This works well for the main form. Its drawn properly, no problems.
When I create a child window and initialize it as mentioned it runs ok; the global WNDPROC routes all messages via the SetWindowLong/GetWindowLong to the window and they are handled ok. ALL BUT THE WM_PAINT MESSAGE. The application crashes with a runtime error. The same occurs with WM_NCPAINT.
WM_GETMINMAXINFO, WM_CREATE, WM_NCCREATE etc are all working well, except the paint messages.
Here's the global WNDPROC.
<br />
LRESULT CALLBACK<br />
WinControl::GlobalWndProc(HWND pHWnd, UINT pMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
LRESULT nResult = 0;<br />
<br />
WinControl * nControl = NULL;<br />
<br />
MSG nMsg = { 0 };<br />
<br />
WinCriticalSection nLock;<br />
<br />
LPCREATESTRUCT nLPStruct = { 0 };<br />
<br />
nLock.Lock();<br />
<br />
nControl = reinterpret_cast<WinControl *>(::GetWindowLong(pHWnd, GWL_USERDATA));<br />
<br />
if((nControl == NULL) && (pMsg == WM_NCCREATE))<br />
{<br />
nLPStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);<br />
<br />
nControl = reinterpret_cast<WinControl *>(nLPStruct->lpCreateParams);<br />
<br />
::SetWindowLong(pHWnd, GWL_USERDATA, (LONG)nControl);<br />
}<br />
<br />
if(nControl == NULL<br />
{<br />
nResult = ::DefWindowProc(pHWnd, pMsg, wParam, lParam);<br />
}<br />
else<br />
{<br />
nMsg.hwnd = pHWnd;<br />
<br />
nMsg.lParam = lParam;<br />
<br />
nMsg.wParam = wParam;<br />
<br />
nMsg.message = pMsg;<br />
<br />
nResult = nControl->WndProc(&nMsg);<br />
<br />
nControl = NULL;<br />
}<br />
<br />
nLock.Unlock();<br />
<br />
return nResult;<br />
}<br />
<h>Hope is the remainder of the of the number of times you thought you wouldn't make it divided by infinity. - e.m
|
|
|
|
|
You're using some third party library that likely has bugs.
You do not need, nor should you, use a critical section in your main procedure.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
modified on Monday, February 18, 2008 10:12 PM
|
|
|
|
|
Joe Woodbury wrote: You're using some third party library that likely has bugs.
My project has no external dependencies other than those windows provided. Am trying to build a GUI framework from the ground up.
Joe Woodbury wrote: You do not need, nor should you, use a critical section in your main procedure.
You're right there, had not done enough reading.
This bug is starting to get to me.
<h>Hope is the remainder of the of the number of times you thought you wouldn't make it divided by infinity. - e.m
|
|
|
|
|
I don't see any problems in the code you've shown.
Where is it crashing? Stepping into the nControl->WndProc(&nMsg) call
on a WM_PAINT message - where does it crash?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I stepped through the
nControl->WndProc(Msg & nMsg)
and found that nControl was not a valid pointer. This was irregular because it only happened when the WM_PAINT and the WM_NCPAINT were sent to the window.
Here's the history:
I have a class, WinControl that is responsible for wrapping methods related to manipulation of a windows control. It has a RegisterWindowClass method that creates the WNDCLASSEX passing it to the the native RegisterClassEx API function. The lpfnWndProc is set to point to a public static GlobalWndProc member function of the WinControl class.
Upon window creation using CreateWindowEx all windows messages are passed to the GlobalWndProc function. In here the HWND sent by windows is associated with the WinControl being created (when the WM_NCCREATE message is received):
SetWindowLong(theHWND, GWL_USERDATA, pointerToTheWinControlObtainedFromTheLPARAM)
On subsequent system messages, the WinControl mapping to the HWND supplied by the system is retrieved by:
GetWindowLong(theHWND, GWL_USERDATA)
Once retrieved the message is passed to a protected WndProc method in the WinControl class where using the this pointer, the window is able to consume it appropriately.
The problem was arising because the retrieval of the WinControl was failing, specifically during the WM_PAINT message.
After lots of cursing, gnashing of teeth, the following workaround seems to have settled the issue:
1. Associate the WinControl's HWND using:
static VOID
AssociateControlWithHWnd(IN CONST WinControl * pControl,
IN CONST HWND pHWnd)
{
if(pHWnd != NULL)
{
SetWindowLongPtr (pHWnd, 0, 0);
SetWindowLongPtr (pHWnd, 8, (LONG_PTR) pControl);
SetWindowLongPtr (pHWnd, GWLP_USERDATA, improbableWindowNumber);
}
}
2. Retrieve the WinControl's HWND using:
static WinControl *
GetControlFromHWnd(HWND pHWnd)
{
if((pHWnd != NULL) && (::GetWindowLong(pHWnd, GWLP_USERDATA) == improbableWindowNumber))
{
return reinterpret_cast<WinControl *>GetWindowLong(pHWnd, 8));
}
return NULL;
}
where improbableWindowNumber = 0xf965aa01 .
I bumped onto JUCE and after a tweaking a thing or two, with the above code, the nControl was retrieved successfully and all messages were routed without any problems.
And that is half a day of my life I will never get back.
Thanks for the concern.
<h>Hope is the remainder of the of the number of times you thought you wouldn't make it divided by infinity. - e.m
|
|
|
|
|
could anyone tell me briefly how this code is working?please help me.
<br />
<br />
<br />
#include "tools.h"<br />
<br />
#include "ltisys.h"<br />
<br />
#include "nonrec.h"<br />
<br />
<br />
<br />
int main()<br />
<br />
{<br />
<br />
Graph gr(3,2,"Non-Recursive Filter Design");<br />
<br />
<br />
<br />
<br />
LTISystem lp = NRLowPass(0.1,63);<br />
<br />
lp.a.plot(gr,1,"Low-pass at 0.1","Samples","Amp");<br />
<br />
<br />
<br />
<br />
Spectrum lpf(500,1000);<br />
<br />
for (int i=0;i<500;i++) lpf[i] = lp.response(i/1000.0);<br />
<br />
lpf.plotLogMag(gr,2,"Frequency Response");<br />
<br />
<br />
<br />
<br />
LTISystem hp = NRHighPass(0.4,63);<br />
<br />
hp.a.plot(gr,3,"High-pass at 0.4","Samples","Amp");<br />
<br />
<br />
<br />
<br />
Spectrum hpf(500,1000);<br />
<br />
for (int i=0;i<500;i++)<br />
<br />
hpf[i] = hp.response(i/1000.0);<br />
<br />
hpf.plotLogMag(gr,4,"Frequency Response");<br />
<br />
<br />
<br />
<br />
LTISystem bp = NRBandPass(0.2,0.3,63);<br />
<br />
bp.a.plot(gr,5,"Band-pass at 0.2-0.3","Samples","Amp");<br />
<br />
<br />
<br />
<br />
Spectrum bpf(500,1000);<br />
<br />
for (int i=0;i<500;i++) bpf[i] = bp.response(i/1000.0);<br />
<br />
bpf.plotLogMag(gr,6,"Frequency Response");<br />
<br />
<br />
<br />
gr.close();<br />
<br />
}<br />
<br />
<br />
<br />
#include "tools.h"<br />
<br />
#include "ltisys.h"<br />
<br />
#include "nonrec.h"<br />
<br />
#include "kaiser.h"<br />
<br />
<br />
<br />
const int MAXKAISERWIN=256;
<br />
<br />
<br />
<br />
LTISystem KaiserLowPass(<br />
<br />
double freq,
<br />
<br />
double ripple,
<br />
double twidth
<br />
<br />
)
<br />
{<br />
<br />
int i;<br />
<br />
<br />
<br />
<br />
Waveform kwin = Kaiser(ripple,twidth,MAXKAISERWIN);<br />
<br />
int nhalf = kwin.count()-1;<br />
<br />
<br />
<br />
<br />
<br />
double omega = 2*PI*freq;<br />
<br />
for (i=0;i<=nhalf;i++)<br />
<br />
kwin[i+1] *= omega*sinc(i*omega)/PI;<br />
<br />
<br />
<br />
<br />
LTISystem lpfilt(2*nhalf,0);<br />
<br />
lpfilt.a[nhalf] = kwin[1];<br />
<br />
for (i=1;i<=nhalf;i++) {<br />
<br />
lpfilt.a[nhalf-i] = kwin[i+1];<br />
<br />
lpfilt.a[nhalf+i] = kwin[i+1];<br />
<br />
}<br />
<br />
<br />
<br />
return lpfilt;<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
int main()<br />
<br />
{<br />
<br />
int i;<br />
<br />
<br />
<br />
<br />
Graph gr (2,2,"Kaiser Window Design");<br />
<br />
<br />
<br />
<br />
Waveform kwv1 = Kaiser(40.0,0.005,MAXKAISERWIN);<br />
<br />
kwv1.plot(gr,1,"Kaiser (40dB/0.005)");<br />
<br />
<br />
<br />
<br />
LTISystem lp1 = KaiserLowPass(0.1,40.0,0.005);<br />
<br />
Spectrum lpf1(500,1000);<br />
<br />
for (i=0;i<500;i++) lpf1[i] = lp1.response(i/1000.0);<br />
<br />
lpf1.plotLogMag(gr,2,"Frequency Response");<br />
<br />
<br />
<br />
<br />
Waveform kwv2 = Kaiser(80.0,0.01,MAXKAISERWIN);<br />
<br />
kwv2.plot(gr,3,"Kaiser (80dB/0.01)");<br />
<br />
<br />
<br />
<br />
LTISystem lp2 = KaiserLowPass(0.1,80.0,0.01);<br />
<br />
Spectrum lpf2(500,1000);<br />
<br />
for (i=0;i<500;i++) lpf2[i] = lp2.response(i/1000.0);<br />
<br />
lpf2.plotLogMag(gr,4,"Frequency Response");<br />
<br />
<br />
<br />
gr.close();<br />
<br />
}<br />
<br />
|
|
|
|
|
Try reading the article you copied this from: http://www.phon.ucl.ac.uk/courses/spsci/dsp/lpc.html[^]
If you don't understand digital signal processing, learn that first.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
ashwiny wrote: could anyone tell me briefly how this code is working?
Which part exactly?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I'm trying to paint a Bitmap in my dialog. Got as far as:
CWnd* pWnd =GetDlgItem(IDC_LOGO);
if(pWnd){
CDC* pDC=pWnd->GetDC();
CBitmap Bmp;
Bmp.LoadBitmap(IDB_LOGO);
pDC->SelectObject(&Bmp);
// What Next to Paint it
}
My Bitmap painting skills are very seldomly excersised, and got a bit rusty as a result.
Bram van Kampen
|
|
|
|
|