|
This CodeGuru thread may provide a clue.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
The following code is for get the default printer
<br />
PRINTER_INFO_2 *ppi2 = NULL;<br />
DWORD dwNeeded = 0;<br />
DWORD dwReturned = 0;<br />
<br />
EnumPrinters(PRINTER_ENUM_DEFAULT, NULL, 2, NULL, 0, &dwNeeded, &dwReturned);<br />
if (dwNeeded == 0) <br />
return FALSE;<br />
<br />
ppi2 = (PRINTER_INFO_2 *)GlobalAlloc(GPTR, dwNeeded);<br />
if (!ppi2)<br />
return FALSE;<br />
<br />
bFlag = EnumPrinters(PRINTER_ENUM_DEFAULT, NULL, 2, (LPBYTE)ppi2, dwNeeded, &dwNeeded, &dwReturned);<br />
if (!bFlag)<br />
{<br />
GlobalFree(ppi2);<br />
return FALSE;<br />
}<br />
<br />
if ((DWORD)lstrlen(ppi2->pPrinterName) >= *pdwBufferSize)<br />
{<br />
*pdwBufferSize = (DWORD)lstrlen(ppi2->pPrinterName) + 1;<br />
GlobalFree(ppi2);<br />
return FALSE;<br />
}<br />
<br />
lstrcpy(pPrinterName, ppi2->pPrinterName);<br />
Best Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Thanks for all those who replied.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
hi:
how to chang the tooltip of the buttons on the toolbar?I use CToolTipCtrl::updateTipText() to do so,but only some buttons chang the tooltip texts,others don't,why?
Thanks
benben
|
|
|
|
|
There's a good chance these tips are loaded from resources. In the toolbar's parent window, you can handle TBN_GETINFOTIP to eliminate the default behavior.
--------
all the modern things
have always existed
they've just been waiting
to come out
and multiply
and take over Björk, The Modern Things
|
|
|
|
|
hi
i have this code that should take the data in "m_copyed" and increment it by the value in "keyvalue".
But i seems to only increment the data by '1' and ignoring the value in "keyvalue"
radio_select=3;
for(int i=m_copyed.GetLength();i--;)m_copyed.SetAt(i,m_copyed[i]+ keyvalue);
SetDlgItemText(IDC_CHANGEDDATA, m_copyed);
i have some extra code in another area of the program shown below code this be the problem>
GetDlgItemText(IDC_EDITDATA, m_typing);
m_copyed=m_typing;
NOTE - i have 2 edit boxs "m_copyed" and "m_typing", i'm taking the text from "m_typing" incrementing it by the value in "keyvalue" and then displaying it in "m_copyed"
any help would be appreciatted
thanks
|
|
|
|
|
You've forgotten the most important thing: where is keyvalue set, and what to ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
ive just declared it as an 'int'
and set the edit text to m_key="ENTER KEY";
not sure where else i should set the value
thanks for the help
|
|
|
|
|
But to what value and where ? What are you trying to achieve ?
|
|
|
|
|
i havent set it at any value.
when the program is ran, the user enters a value which is stored as "keyvalue".
This value say '2' is used to move the text in "m_typed" by 2 positions. So if the word was 'SUMMER' it would become 'UWOOGT'
|
|
|
|
|
wrote:
when the program is ran, the user enters a value which is stored as "keyvalue".
You're converting the value typed in to a number, right ? Or you're calling UpdateData() before using the value if you've set it to be an int in the Class Wizard ?
wrote:
when the program is ran, the user enters a value which is stored as "keyvalue".
This value say '2' is used to move the text in "m_typed" by 2 positions. So if the word was 'SUMMER' it would become 'UWOOGT'
I just wanted to verify this is what you wanted to do. I reckon you're forgetting to call UpdateData before using the variable.
|
|
|
|
|
i have inserted a background image on my dialog by using pDC->StrecthBlt(...)
and i could not be able to set the background of my static controls into what my dialog is although i have set my Background mode to TRANSPARENT (pDC->SetBkMode(TRANSPARENT).
They still have "gray background color" and i have trouble with them.
Anyone who have an idea to solve my problem?
Thanks for ur help...
Atilla Selem
just listening to you...
|
|
|
|
|
Hi,
I am working on making my app a Windows Script Host. So far I have a class that entirely works. You might say why do I need help?
Well, here's the thing. I can add an automation object to the engine so that I can have my own methods. But if I don't name the object in ParseScriptText (2nd parameter), it never finds the 'new' functions when I run the script.
Therefore, I can make it work when there is one object (by naming it in ParseScriptText), but not if I have 2 or more since there is only one param.
Do I have to call ParseScriptText in a loop for all added name objects to get more than one object to work with the engine?
Thanks in advance,
Simon
|
|
|
|
|
I think you need to look into using AddNamedItem which is part of IActiveScript.
My code uses something like
void CLittleScript::ParseScript(LPCTSTR sScript)
{
EXCEPINFO ei;
_bstr_t bstrParseText(sScript);
HRESULT hr = m_iScriptParse->ParseScriptText(bstrParseText.copy(),
NULL , NULL,NULL,0,0,SCRIPTTEXT_ISVISIBLE, NULL,
&ei);
if(hr == S_OK)
{
hr = m_iScript->SetScriptState(SCRIPTSTATE_CONNECTED);
}
else
{
littleDebugger()->Error("Failed to Parse Script Text %x", hr);
}
}
HRESULT CLittleScript::AddScriptObject(LPCSTR sObjectName, IUnknown* pObject)
{
m_ScriptSite.AddScriptObject(sObjectName, pObject);
HRESULT hr = m_iScript->AddNamedItem(_bstr_t(sObjectName),
SCRIPTITEM_ISVISIBLE | SCRIPTITEM_ISSOURCE);
if(hr != S_OK)
{
littleDebugger()->Error("Failed to add named item %x", hr);
}
return hr;
}
In my ActiveScriptSite::GetItemInfo, I loop through for the required object interface.
if(dwReturnMask & SCRIPTINFO_IUNKNOWN)
{
for(int nLoop = 0; nLoop < m_collectionObjects.Count(); nLoop++)
{
SCRIPTOBJECT* pObject = m_collectionObjects.GetItem(nLoop);
if(pObject)
{
_bstr_t a(pObject->m_sName.c_str());
if(!_wcsicmp((const wchar_t*)a, pstrName))
{
(*ppunkItem) = pObject->m_pObject;
pObject->m_pObject->AddRef();
break;
}
}
}
}
Michael
Communication is the first step towards enlightenment.
|
|
|
|
|
Hi, I'm still a bit new to MFC and I'm having a really silly problem with it.
I'm trying to make a dialog based program that will allow someone to pick a text file, the program loads it up and then there will be a list of things. No probs on getting to pick the txt file but what I need is for the program to be able to notice duplicate entries in the txt file and then pick one of them out, ignoring the rest of the duplicates.
Also, even sillier, I need to make something that displays a bunch of strings that contain text in them. I'm having the problem though that some of the strings that I need it to show contain things like
ReplyHello=/ :-: \
ReplyHelp=Help?
whenever I try to do a
CString m_something=(_T("ReplyHello=/ :-: \\nReplyHelp=Help?"));
I get errors about teh escape codes.
Any help for a lost soul? Thanks
|
|
|
|
|
carrie wrote:
I'm trying to make a dialog based program that will allow someone to pick a text file, the program loads it up and then there will be a list of things. No probs on getting to pick the txt file but what I need is for the program to be able to notice duplicate entries in the txt file and then pick one of them out, ignoring the rest of the duplicates.
Easy - let STL do the dirty work for you. If you store the information in an STL set, it will discard duplicates as you go. I've written an article on this, just search for 'graus map set' to find it. You can also read a text file into an STL container in just three lines of code - I show that in my STL articles as well.
I don't see anything wrong with the string you're setting, but if you're getting an escape code erro,r chances are you tried to insert a \, and forgot to put two of them, as \\ is the code for \, as \ denotes the begining of an escape code, such as \n for newline, or \r for return.
Don't feel silly, you should see some of the stuff I asked when I was starting. We all start somewhere.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
I'm trying to display ToolTips on one of my dialogs using
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotification)
It only works for some of the controls. I've used Spy++, and the non-working controls just aren't firing the WM_NOTIFY message. Anyone know what to do about this?
(I have a couple of frames on the dialog - will that mess things up?)
|
|
|
|
|
This article may help.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
When I create a "MFC EXE" project with "Dialog Based" application I have at the begining 2 classes in it: Application class and Window class. When I add menu to the window and write message handler (for example OnExit) for menu item click, my window class disappears from the project! The source code files for that class are still in the project, but no class
After few seconds the application class follows the window class
Is that a bug for Visual C++ 6 IDE? How can I solve that problem?
Thank you.
Igor Urdenko
|
|
|
|
|
Class wizard is getting confued. You can normally solve this problem by deleting the projects .clw file. Then start up class wizard again and hopefully your class list will be restored.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
I have removed *.clw file. In Class Wizard I can see my window class, but it is still not in ClassView... I am sorry, I am newbie, but how can I add new messages handlers to my class if it is not in ClassView?
Thank you.
Igor
|
|
|
|
|
To add message handlers manually, for each you need to add a prototype
afx_msg void OnMyNewHandler()
This needs to go before the DECLARE_MESSAGE_MAP macro in the .h file.
Add a message map entry in the .cpp file
ON_COMMAND(IDC_OF_COMMAND, OnMyNewHandler)
Add the function
void CMyClass::OnMyNewHandler()
{
}
If you need to put in an update handler
afx_msg void OnUpdateMyNewHandler(CCmdUI *pCmdUI) ;
ON_UPDATE_COMMAND_UI(IDC_OF_COMMAND, OnUpdateMyNewHandler)
void CMyClass::OnUpdateMyNewHandler(CCmdUI *pCmdUI)
{
pCmdUI->Enable(...) ;
}
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Thank you for the help provided.
Ingvar
|
|
|
|
|
.CLW is the file for ClassWizard; and .NCB is the file for ClassView. You should close the project, delete the .NCB file, then open the project again.
Visual C++ doesn't handle template really well. When I add some function templates or template classes, ClassView would behave abnormal. And sometimes syntax error causes such condition, too.
Feel free to delete .ncb files!
|
|
|
|
|
Yes! It works! Thank you very much for that help!
Igor
|
|
|
|