|
CString strText("GOOD");
char *pChar= (char *)(LPCTSTR)strText;
|
|
|
|
|
Please never suggest that unless you further elaborate.
Such conversion may be used only with extreme care.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Do you mean to say i should elaborate what i have given there an an example?
|
|
|
|
|
I mean since your technique is dangerous hence you should explicitely state whenever it is viable.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
I have been looking for a way to access the dictionary in windows.
I have found how to spell check and to edit the dictionary but that is doing a comparison of words in a file utilizing msword.olb in C++.
I am looking to pull a word from the dictionary with the option of pulling the definition with it. Is that possible within the C++/.net environment to utilize the dictionary built into word or word pad this way?
|
|
|
|
|
Hi
I want to make a program that retrieves other windows' pixel values. First i made a default application which title name is "Untitled - NewWindow" and one more MFC project which is trying to draw to that window.
The code is:
void CDeviceContextDlg::OnBnClickedButton1()
{
::EnumWindows(EnumWindowsProc, NULL);
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
if(hwnd == FindWindow(NULL,L"Untitled - NewWindow"))
{
HDC dc = GetDC(hwnd);
CDeviceContextDlg *dlg = (CDeviceContextDlg *)AfxGetMainWnd();
if((dlg->Clientdc.Attach(dc)))
{
dlg->Clientdc.SetBkColor(RGB(255,0,0));
};
};
return TRUE;
}
It gives run-time error. I debugged it and in that line:
HDC dc = GetDC(hwnd);
In Debugger:
dc 0x53011041 {unused=??? } HDC__ *
unused CXX0030: Error: expression cannot be evaluated
Is it because process gdi handle table is process specific and it is impossible to get DC and draw another process' window?
Or is there a way to draw another process' window or getpixel values?
Thanks
|
|
|
|
|
Maybe this [^] helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Just fixed the vote on this post of yours.
|
|
|
|
|
Thank you friend.
Anyway don't bother. Let's my personal troll having a touch of glory...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am searching ebay for a device that would let you find and punch one troll at a time, with a folded fist, through the internet.
|
|
|
|
|
Well, you can buy one (ore more) of these [^] and then proceed with voodoo ceremony.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
I tested this real quick, and it works fine for me.
This example finds a NotePad instance and Blts the Notepad window
to my window (note that "*pThis" in the callback == the HWND for the dialog window)...
BOOL CALLBACK CMFCTesterDlg::EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
if(hwnd == ::FindWindow(NULL, L"Untitled - Notepad"))
{
CMFCTesterDlg *pThis = (CMFCTesterDlg *)lParam;
HWND hwnddest = *pThis;
RECT rect;
::GetWindowRect(hwnd, &rect);
HDC dc = ::GetDCEx(hwnd, NULL, DCX_WINDOW);
HDC destdc = ::GetDC(hwnddest);
::BitBlt(destdc, 0, 0, rect.right-rect.left, rect.bottom-rect.top, dc, 0, 0, SRCCOPY);
::ReleaseDC(hwnddest, destdc);
::ReleaseDC(hwnd, dc);
};
return TRUE;
}
void CMFCTesterDlg::OnOK()
{
::EnumWindows(&CMFCTesterDlg::EnumWindowsProc, (LPARAM)this);
}
Also, why the search within a search (FindWindow() within an EnumWindows() callback)??
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you Mr.Mark Salsbery. Got it.
|
|
|
|
|
iwdu150
I have tried your Percent Progress Bar, and have use it in a application I am building. What I mean is I am using the DLL and the XML. This application that I am building is for my own use and will not be release to the public. The DLL and XML have really come in handy and I have enjoyed using. You did a good job.
The reason I am contacting you is that I noticed that the word ‘TRIAL’ is tacked onto the name ‘Progress Bar Trial.dll’ and ‘Progress Bar Trial.xml’. This has me a little worried, will it expire or maybe die on me in the near future. If not then great; but if so, please let me know. Also let me know how I can get a good copy of it. Once again, great job, I hope I can use it just the way it is.
Bob Allan
rallan@carolina.rr.com
|
|
|
|
|
|
robertaallan wrote: ...will it expire or maybe die on me in the near future.
Don't you have the source code?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm having a problem positioning dialog boxes on a tab control. I create the dialog box passing it the tab control handle as the parent window.
Here's an image of the results:
Tab Control/Dialog Box Problem[^]
The dialog box covers up the tab buttons. Do I have to manually position the dialog box so that it doesn't cover up the buttons?
Note, I'm not using MFC but straight Win32.
EDIT: Apparently I do have to position the dialog boxes manually in order not to cover up the tab buttons. I adjusted the dialog box's X/Y position to 2/15 and it looks right now.
|
|
|
|
|
From Win32 you can use TabCtrl_GetItemRect[^] to get the rectangle of the tab control.
Best Wishes,
-David Delaune
|
|
|
|
|
Leslie Sanford wrote: I adjusted the dialog box's X/Y position to 2/15 and it looks right now.
TabCtrl_AdjustRect/TCM_ADJUSTRECT will give you the proper
rect that will work regardless of font. Much better than
hard-coded numbers
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: TabCtrl_AdjustRect/TCM_ADJUSTRECT will give you the proper
rect that will work regardless of font. Much better than
hard-coded numbers
Thank you!
Yup, hard-coded numbers are always distasteful.
|
|
|
|
|
In a c++ application I would like to do different printings on different printers but I do not want to
a.) use the print dialog
b.) use the default printer.
So I tried to set up a piece of code but there is a great gab when I want to print on a non-default printer.
The code that I'm using at the moment is looking like this:
//-----------------------------------------------------------------------------------------
iPrintMode = 0; // call PrintDialog
iPrintMode = 1; // use default printer
iPrintMode = 2; // use fixed printer
m_HdcPrint = NULL;
// new class PrintDialog
CPrintDialog *pPrintDlg = new CPrintDialog(FALSE, PD_ALLPAGES | PD_RETURNDC, NULL);
if (iPrintMode == 0 || iPrintMode == 1)
{
if (iPrintMode == 0)
{
// call the default PrintDialog
pPrintDlg->m_pd.nMinPage = 1;
pPrintDlg->m_pd.nMaxPage = 1;
pPrintDlg->m_pd.nFromPage = 1;
pPrintDlg->m_pd.nToPage = 1;
// start Printer-Dialog
pPrintDlg->DoModal();
}
else if (iPrintMode == 1)
{
// use the default printer of this machine/user
pPrintDlg->GetDefaults(); // fill the internal structure
/*
CString printer;
DEVMODE* pDevMode;
pDevMode = pPrintDlg->GetDevMode();
printer = pDevMode->dmDeviceName ;
*/
}
// Returnwerte abholen: Handle to PrinterDevice
m_HdcPrint = pPrintDlg->GetPrinterDC();
}
else if (iPrintMode == 2)
{
// print on a fix printer (e.g. 'HP Color LaserJet 4650 PCL 6')
/*
* ==========================================================================
* =
* =
* ===> here is a big gap that I do not know how to fill ....
* =
* =
* ==========================================================================
*/
}
else
{
// no printing
m_HdcPrint = NULL;
}
// printing is possible
if (m_HdcPrint != NULL)
{
// Create a CDC and attach it to the default printer.
// neuen Device-Context anlegen
m_PrintDC = new CDC;
// attach the given properties
m_PrintDC->Attach( m_HdcPrint );
//...
// set mode to 1/10 mm
m_PrintDC->SetMapMode(MM_LOMETRIC);
// calculate to independent data
m_PrintDC->DPtoLP(&m_DrawRect);
//...
// begin the document
m_PrintDC->StartDoc(_T("Print_My_Document"));
// Start a new page
m_PrintDC->StartPage();
//...
//... and so on
//-----------------------------------------------------------------------------------------
It's working fine with the print dialog as well as with the default printer.
However I have no idea to get it working with a fixed printer (e.g. 'HP Color LaserJet 4650 PCL 6').
I had a look at a few articles at CodeProject, but as a bloody beginner I had to give it up very soon.
Does anyone have experience with a similar problem or does anybody have some (code)-ideas how to solve this.
Thanks in advance
|
|
|
|
|
I'm needing to add functionality to a class that uses a template. In other words, there is a template class in a library that I'm using, I need to use it (there is no escaping it), but I really need to pass an additional parameter to it either via constructor (my preferred solution) or by using a mutator method. The problem is that the compiler refuses to allow me to do two things: 1) add a parameter to the class, and 2) add a parameter to a constructor or add a new method to my class.
Is there a 'proper' way to do this?
|
|
|
|
|
Patrick G wrote: the compiler refuses to allow me to do two things
We can't understand the compiler errors unless you post them along with the relevant code.
led mike
|
|
|
|