|
I wrote one example for you and i change background color from groupbox
whitesky
|
|
|
|
|
get the dc and make it transparent.
hello
|
|
|
|
|
I want to develop an MFC application that has
1. Either a control bar or dialog bar which has some button objects
2. The bar needs to be always accessible. That means I want to be able to click on the buttons on the bar even if a modal dialog showing.
One way I thought of to put the dialog bar in its user thread, but this is almost impossible as it dialog bar needs to send a message to the main windows. Another way was not to show modal dialogs, but this would complicate the design as to manage the number of different dialogs to be displayed.
Any thought as to how to put a controls bar/dialog bar/or even a child windows on its own thread that can always listen to user actions? A pointer to an article or sample code would be great.
Thanks,
/* I can C */
// or !C
Yusuf
|
|
|
|
|
I didn't get the exact situation over there. I will put my suggestions.
If you want to keep the UI alive, It is best to keep it in a separate UI thread and keep posting messages. There is always a defenite way to do that.
Also the use of Modal dialog demands the user to deal with the dialog ,and with nothing else when it is shown. You still have chances of improvement over here.
Sher
|
|
|
|
|
Thanks Sher,
The whole UI doesn't need to be alive, but a portion of it needs to be alive all the time. Think it this way, I want my toolbars to be alive all the time.
I started looking into creating my toolbar as a CDialogBar item which will run in it's own CWinThread. I though this will isolate it from the whole UI message loop. Since the CDialogBar object is created inside the CFrameWnd object, whenever the main UI is blocked, so does goes the second CWinThread which has my CDialogBar object.
I could create my CDialogBar as a child of the Desk top, which solves the blocking issue, but it lives outside the main UI frame, which does not meet my requirement.
Any idea as to how I might be able to solve this?
/* I can C */
// or !C
Yusuf
|
|
|
|
|
DoModal will block its parent by PreModalDialog API and releases using PostModalDialog
Have you tried modeless dailogs?
SaRath.
"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."
My Blog | Understanding State Pattern in C++
|
|
|
|
|
Yes I thought of modeless dialogs. But there is AfxMessageBox() which acts as modal dialog.
I though overriding PreModalDialog(), DoModal() to prevent the main UI from being blocked. it turns out, I will need to handle more cases, and alost have my own CDialog code.
Hmm, I guess I might be trying to do the impossible?
/* I can C */
// or !C
Yusuf
|
|
|
|
|
I'm studying and coding in MFC about Text To Speech in Microsoft Word. I need to find Materials of Text To Speech to present what I'm studing. What page or what material can I find ?
Thanks.
|
|
|
|
|
Use Microsoft speech API in MSDN
Also You can find materials at IBM(IBM's Speech APIs and ViaVoice Documentation).
Herbert
|
|
|
|
|
I don't know Signal Strength.
I codding Signal Strength and no error , run but discontinue.
Why discontinue program. Please Signal Strength program.~~
IWbemServices *pSvc = NULL;
IEnumWbemClassObject * pEnumerator = NULL;
HRESULT hres = pSvc->ExecQuery(bstr_t("WQL"), bstr_t("SELECT * FROM MSNdis_80211_ReceivedSignalStrength Where active=true"),
WBEM_FLAG_FORWARD_ONLY || WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
IWbemClassObject *pclsObj;
ULONG uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj,
&uReturn); //WBEM_INFINITE
if(0 == uReturn)
{
//cout << "Need to BREAK!" << endl;
break;
}
VARIANT vtProp;
VariantInit(&vtProp);
// Get the value of the Name property
hr = pclsObj->Get(L"Ndis80211ReceivedSignalStrength", 0, &vtProp, 0, 0);
// wcout << " OS Name : " << vtProp.bstrVal << endl;
VariantClear(&vtProp);
}
|
|
|
|
|
Hey Guys,
Using the Win32 API, how do I change the text and color in a button once it is clicked? I have tried looking on MSDN and on google, but the process appears to be more complicated than I believe it seems.
I can change the text using SetDlgItemTxt but when using SetTextColor it does not change the color of the text (my guess is that the button is not being redrawn with the new COLORREF parameter).
All I picked up from MSDN is that I have to create a new brush, destroy the dialog control, re-create it with the new text in a different color and then destroy the brush. I dont think its that complicated and hopefully someone can steer me on the right path.
Thanks,
Robbie
|
|
|
|
|
Google and MSDN eh???
Did you look here: http://www.codeproject.com/buttonctrl/[^]
I'm almost 110% postive you'll find a custom control or article which explains just what you want
Cheers
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
I want to implement in Visual C the DOS command "attrib" - to change files attributes such as: read-only, hidden, system. How can I do this?
|
|
|
|
|
|
See Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
Hello there.
I am writing picture editor and I have a problem with saving images to the same file.
Of course I can save them to the different file names, but not to the original filename.
So I've searched and found a page where are couple of steps that I have to do.
1. Open the image file
2. create a temporary in-memory image the same size as the original
3. obtain a Graphics object for the temporary image
4. Draw the original image onto the temporary one
5. dispose of the original
6. do any drawing you'd like on the image using the Graphics you have
7. Dispose of the Graphics
8. Write the temporary file to any filename and any format you please including the same name and format if you wish.
The idea is clear to me, and I know what I have to do, but I have one problem.
There is no such function as Dispose() in GDI+. It is in MFC of course, but not in GDI and I don't know how to "Close the file" so I can save the image under the same filename.
I've tried CloseHandle(HANDLE) function, but it seems it doesn't work.
Can anybody help me with this ?
soyo
|
|
|
|
|
FileStream fs = new FileStream("Sunset.jpg", FileMode.Open);
Bitmap b = new Bitmap(fs);
fs.Close();
Graphics.FromImage(b).FillRectangle(Brushes.Black, 0,0,b.Width, b.Height);
fs = new FileStream("Sunset.jpg", FileMode.Truncate);
b.Save(fs, System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()[0], null );
fs.Close();
"Until the day of his death, no man can be sure of his courage" -- Jean Anouilh
|
|
|
|
|
The Image class does have a Dispose() method, though I never use it, opting to just delete the Image (well usually Bitmap) object.
Do note that for some file formats GDI+ requires that the original stream remain intact. For others, it reads the data in entirely. My solution has been to do what you are doing except for step 8, there I've closed both and then either moved the new file on top of the original, with the flag to not prompt, or deleted the original and renamed the new one.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Dispose() is not available when I don't write in MFC. There is no such function in Image Class under GDI+ section.
How can I delete a file no matter what circumstances ?
For example according to MSDN I cannot use DeleteFile(LPCTSTR) to Read-Only files.
|
|
|
|
|
1980soyo wrote: Dispose() is not available when I don't write in MFC. There is no such function in Image Class under GDI+ section.
My mistake, I was just looking at MSDN documentation. As I said, I always delete the object directly or by letting it go out of scope.
1980soyo wrote: How can I delete a file no matter what circumstances ?
You can't. You can delete a file only if you have permissions to do so and it is not open. If a file is read-only, you can attempt to change the attributes using SetFileAttributes() , but that will work only if you have proper permission and/or security to do so.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi,
I am coding a program in VC++, mfc, in which I am using CString sql almost every where. Each time i use it, I have to declare. I tried declaring it in stdafx.h but I get errors
Budget.obj : error LNK2005: "class CString sqla" (?sqla@@3VCString@@A) already defined in Collect.obj
DeleteCat.obj : error LNK2005: "class CString sqla" (?sqla@@3VCString@@A) already defined in Collect.obj
StdAfx.obj : error LNK2005: "class CString sqla" (?sqla@@3VCString@@A) already defined in Collect.obj
Debug/sbh2.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
I checlked and rechecked a thousand times. I have not made multiple difinition. Then why is this happening?
I thought maybe it is because of 'sql' so I changed it to 'sqla', in vain.
Fortitudine Vinsinues!
|
|
|
|
|
Because this header has been included in the same module many times (maybe recursively)! Normally you can employ certain preprocessor directives to ensure the header only being included once, but in this case, you should avoid declaring variables in a header. An appropriate way is:
1) Declare a global variable in a source file (.cpp) only once:
CString sqla;
2) If any other source file in the same module needs to use this variable, use "extern" keword:
extern CString sqla;
Best,
Jun
|
|
|
|
|
I do not understand
If I declare CString sqla , say in Budget.cpp (a dialog class), then I have to declare it again as extern CString sqla in payroll.cpp (another dialog class)? Is that right
Actually what I am trying to do is declare CString sqla in just one place in the program and then use just sqla directly in any other .cpp file. Is that possible?
Usually, a dialog class has the .cpp file and .h file. If you want to use CString sqla in all the functions of that particular .cpp file, you declare it in the header file. But you cannot use sqla in another dialog class source. You have to declare it again. Is there a way in which I declare it somewhere only once?
Like for example, if math.h is used in many class, you usually #include it in stdAfx.h ...
I hope you can understand what I am trying to say!
-- modified at 15:26 Monday 26th June, 2006
|
|
|
|
|
TheinstruTara wrote: Actually what I am trying to do is declare CString sqla in just one place in the program and then use just sqla directly in any other .cpp file.
Unless you are assigning a value to the CString object that changes infrequently, why are you doing this? Why not just create an instance of the object at the point it is needed?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am using the CString object, sql almost every where. I use it to assign an sql "SELECT * FROM...." . The sql changes in different places. And everytime I have to asign something, I have to declare CString sql. That is why I am trying to make it global, so that I do not have to declare it again and again.
Fortitudine Vinsinues!
|
|
|
|