|
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!
|
|
|
|
|
TheinstruTara wrote: That is why I am trying to make it global, so that I do not have to declare it again and again.
Why? What's wrong with a variable being declared when it is needed? You're not saving anything by using a global variable instead. That way of thinking has not been relevant with Windows in a number of years.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Well..I am not trying to save anything.
I have to type CString sql; everytime I have to use it. I guess just a bit lazy... And if there is a better way of doing it, then why not!
I do know that if a variable can be declared as totally global. Just wasn't sure how.
I guess, we all try to find easier way of doing things.Some toothbrush company has come out with, 'automated toothbrush' Batery operated stuff...
Fortitudine Vinsinues!
|
|
|
|
|
Automated Tooth brush is alreay there...But there is no available medicine for lazyness till now...
Look here.
http://www.pricegrabber.com/search_attrib.php/page_id=796/popup1%255B%255D=20:1765/
Pls dont ask for a stuff which have food for u
|
|
|
|
|
While you can use the extern solution provided, a better solution for you would be to define that string in your string table and declare a CString object to use it when needed.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
TheinstruTara wrote: then I have to declare it again as extern CString sqla in payroll.cpp (another dialog class)?
Keyword "extern" indicates that this variable has been declared elsewhere in the same module and tells the compiler to use that declaration.
TheinstruTara wrote: If you want to use CString sqla in all the functions of that particular .cpp file, you declare it in the header file.
That may be what you have been doing, but it's not right. You don't declare varaibles in a header, you only put macros, constants, type definitions (that sort of things) there.
In essense, header is about definition not declaration. People include your header because they want to use your type definitions, not the variables in your module!
Hope this is clearer.
Best,
Jun
|
|
|
|