|
I took this code directly from Tom Armstrongs book, Designing and Using ActiveX Controls.
I am trying to implement the 1st example. A COM/MFC Edit control. The code is meant to set the background and forground colors of the activex controls to that of its contanier.
The problem is it makes both color sets black. Any suggestions on how the code should be writen?
LRESULT CEEditCtrl::OnOcmCtlColor(WPARAM wParam, LPARAM lParam)
{
if(m_pBackBrush == NULL)
m_pBackBrush = new CBrush(TranslateColor(GetBackColor()));
CDC* pdc = CDC::FromHandle((HDC)wParam);
pdc->SetBkMode(TRANSPARENT);
pdc->SetBkColor(TranslateColor(GetBackColor()));
pdc->SetTextColor(TranslateColor(GetForeColor()));
HBRUSH far* hbr = (HBRUSH far*)m_pBackBrush->GetSafeHandle();
return (DWORD) hbr;
return NULL;
}
thank you
|
|
|
|
|
How can i compare 2 wav files?Can anyone show me or email me some code? (costexx@hotmail.com)I want to know if it's the same sound.
|
|
|
|
|
Do you want to know if they *sound* the same, or *are* a copy of the same file ?
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Two entirely different things eh?
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Nish [BusterBoy] wrote:
Two entirely different things eh?
Nish you should move to Canada, your half way there already
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
Nish [BusterBoy] wrote:
Two entirely different things eh?
Nish you should move to Canada, your half way there already
To be frank, though I understand that there is humor hidden there somewhere, I cannot find it
Will someone throw a light here please?
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Canadians are fond of saying "eh ?"
Check out the movie "Strange Brew" for amusing examples of stereotypical Canadian speech.
|
|
|
|
|
Rick York wrote:
Canadians are fond of saying "eh ?"
Oh! I dont say "eh" too often, but I do write "eh" sometimes. When I talk I replace "eh" with "huh". I think I have three or even four variations of "huh" according to the need of the situation.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
That makes you closer to an american than a Canadian.
There are no small projects - only young ones.
|
|
|
|
|
Like CG, i dunno if you want binary comparison or I guess mathematical if you were checking for sound similarity.
Anywho, if you want binary...why not just use windiff...?
However you probably want sound cuz why would you be specific about wav files and not just generic and say files.
Sounds like the latter would be tricky.
Good luck!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I've created a modal dialogbox using DialogBox(). The dialog has 2 editboxes and I want the text they contain to somehow be returned to the parent, so I can use them. I thought of using the returnvalue of DialogBox(), which is what I specify when I call EndDialog() from within the dialogbox procedure, and let it point so some structure with 2 strings. But is this the correct approach? I also do not want to use global variables.
Any good ideas?
Sprudling
PS! I'm not using MFC; just plain Win32 API stuff...
|
|
|
|
|
1. Make a struct that holds the data (pointers, std::strings, whatever you're using)
2. Use DialogBoxParam() and pass a pointer to that struct as the dwInitParam parameter.
3. In your dialog's window proc, the lParam sent with WM_INITDIALOG is that pointer. Save it with SetWindowLong(hwndDlg, DWL_USER, lParam);
4. Whenever you need to access that pointer again, use GetWindowLong().
--Mike--
#include "witty-sig.h"
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Just add 2 strings to your dialog box class. Either make them public or write accessor functions. After DoModal returns your dialog object is still valid and you get the values via dlg.GetValue1(), dlg.GetValue2().
A vast majority of our imports comes from outside the country.
George W. Bush
|
|
|
|
|
Where do I put the code that should react on pressing enter in a combobox?
The ComboBox is created in MainFrame.
Where should I do the messagemap?
Thanks in advance.
-- Kelthar :: icq9071676 :: http://www.bilbomb.com/ --
|
|
|
|
|
Do it whereever you find the resource id for the combobox in classwizard
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Can anyone tell me what exactly the export definition file is for?? In Visual studio i build this DLL which has a .def file in the workspace and it has two exports defined, everything compiles great. Now when i compile under Mingw i get an error that i dont have a .def file but that one will be created for me, but its got all sorts of functions and weird chars in it and its totally different from the one in VC++. So i tried to just copy the .def file cause its the same DLL and all but then when i try to compile with the .def file in my workspace (Dev-C++) i get some error saying "def file unused since linking not done" or something...
Can someone explain what the .def file is for, and if its even that necessary to include??
Thanks for any help.
Kuniva
--------------------------------------------
God gave man a penis and a brain but not enough blood to make both of 'em work at the same time.
|
|
|
|
|
It has to do with compiler mangling of function names. For example, take the function:
__declspec(dllexport) int __stdcall foo(int a, int b);
The complier mangles the function name into _foo@8 , where 8 is the number of bytes passed as parameters. If you try to link this function with another vendors compiler, it will look for foo (or whatever its compiler might mangle the function name into) instead of _foo@8 , and come to the conclusion that no such function exists in the dll. If you have provided an .def file with the line: "EXPORTS foo", the linker parses the file, and exports foo instead.
I don't know about the additional functions you get (exported from other linked modules?), but you probably need a .def file for the functions you export yourself.
/moliate
|
|
|
|
|
I am making an MFC dialog based application. I need to have edit boxes appear while the program is running. How do i do this?
|
|
|
|
|
Use ShowWindow(SW_SHOW) and ShowWindow(SW_HIDE) to show and hide controls on a dialog.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Use CreateWindow() or CreateWindowEx() with "EDIT" as classname and with the WS_CHILD windowstyle to create the editbox.
Read about CreateWindowEx here.
Sprudling
|
|
|
|
|
Add CEdit member variables to your dialog class and call Create on them when you want to.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Poor bloke. He got three equally accurate, but totally different, answers...
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi,
Given: a multithreaded app with a worker threadfunction as below:
UINT TreadFunction(...)
{
Sleep(nDuration);
}
Sleep(nDuration) tries to model a data read operation of unpredictable length from an external device. The read in operation blocks the execution of the thread just like Sleep does. nDuration depends on the actual speed of the device.
Usually, nDuration is < 1 sec, which is quite acceptable for displaying the data afterwards. However, when shi#t happens it might even take up to 1 min for all the data to be read in which is unacceptable because my other threads cannot access the device in the meantime in order to retrieve other kind of data (concurrent access of device is not allowed)
In case of slowed down read I would like to terminate the execution of the above treadfunction after a pre-defined amount of time has elapsed REGARDLESS of the data having been completely read in or not. Of course, partial data could only be displayed in this case.
E.g:
Protection (let's call it so): tread can execute not more than 5 secs.
in 95% nDuration < 5 sec. (Protection does nothing, threadfunc terminates normally, full data is displayed)
in 5% nDuration > 5 sec. (Protection makes the threadfunc terminate prematurely, partial data is displayed)
Do you have an idea how to do that?
Thanks
Pepe
|
|
|
|
|
Hmmm... well, I'm not sure that Sleep is conceptually the same as a blocking fn, but I see your point.
Is there any way to use a non-blocking call, or perhaps set a read timeout on the operation (is this a socket or serial device?)
If not, the only thing I can think of is a TerminateThread issued by a controlling thread when a timer expires - a muchly to be avoided construct. However, if you know that termination is safe (nothing to cleanup) and there's only ever one thread reading (meaning only one timer to set up) it might not be too bad... (no flames please! )
|
|
|
|
|
The serial port is concerned.
Non-blocking calls are not possible because the device manufacturer supplied an ActiveX to be used.
TerminateThread sounds not bad because there is nothing to clean up. I will definitely try it.
But could you please clarify what you meant by setting a read timout?
Thanks for your help.
Pepe
|
|
|
|