|
|
I've having all kinds of memory corruption with _bstr_t. I was also told that _bstr_t was the devil and never use it, even if my life depended on it So I made this useful function to load strings
_bstr_t LoadStringEx(HMODULE hModule, int ID)
{
CComBSTR bstrTemp;
bstrTemp.LoadString( hModule, ID );
_bstr_t strT( bstrTemp.m_str, FALSE );
return strT;
}
I could use the LoadString function from CComBSTR and CStringT directly too...
Thanks!
---------------
Tired of Spam? Introducing InboxShield® for Microsoft® Outlook®
http://www.edovia.com
|
|
|
|
|
_bstr_t has it's problems, but is not THAT bad that I would avoid using it. CComBSTR is better, but does not provide the functionality that _bstr_t does. Why not write your own BSTR wrapper ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Hi,
In the near future I'm going to have to extract some text from PDF documents, as well as search the text in them. Can anyone recommend a good library? It would be good if it was cross-platform and didn't have redistribution costs.
Thanks,
Stuart
|
|
|
|
|
There's some good stuff on SourceForge. Do you need to work with PDF's that are compressed ? I don't think it would be too hard to write the code to decompress them anyhow, and then it's just cleartext, easy to search for.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
A technique I have found useful for PDF document that have copy protection turned on (so you cannot just cut&paste the text or such like) is to do the following:
Add a dedicated-purpose printer, Name=PSPrinter, based on some good Postscript printer (say, HP LaserJet 5000 Series PS). Set the port to FILE.
Then print the PDF to a postscript file using AcroRd32.exe like:
AcroRd32.exe /n /t file.pdf PSPrinter "HP LaserJet 5000 Series PS" file.ps
(use full pathnames for everything here)
The resulting file.ps is easily parsed for text or (if it is well-behaved) passed to GhostView which allows for search and extract of text.
Note: you cannot just print to a "Generic/Text" printer as AcroRd32.exe will often refuse to print to a printer that cannot make an exact copy (for this very reason, I suspect).
Good luck!
|
|
|
|
|
I loaded records from a database and would like to set the first row in a list (CListCtrl) selected to match the first record in the dataset. For example, SetCurSel(n) in CComboBox selects the row.
Eilzabeth
|
|
|
|
|
|
HWND FindWindow(LPCTSTR lpszClassName, LPCTSTR lpszWindowName)
I know I can use NULL as the first parameter but just curious, given all source code of a project, how do you know the "class name" of a CWnd? Also, is there any way to change the "class name"? Thank you.
|
|
|
|
|
That depends. For instance, controls usually have very specific window classes, for instance buttons are "BUTTON", so if you want to find all the edit controls with a specific bit of text, you use FindWindow("EDIT", "TEXT").
For more generic windows, and MFC, you can use Spy++ to find the window class if you like.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
Bin wrote:
how do you know the "class name" of a CWnd?
The easiest way is by spying on the window (Spy++).
Bin wrote:
is there any way to change the "class name"?
The framework assigns a default class name to CWnd-derived objects. I believe the easiest way to change it is by overriding the PreCreateWindow method.
Regards,
Alvaro
All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain
|
|
|
|
|
I tried to override CMainFrm's PreCreateWindow method and set "cs.lpszClass = _T("my test window");" but then got "Failed to create empty document" error message. What else has to be done? Thank you.
|
|
|
|
|
I think it's important to register your own window class before assigning it's name to lpszclass. Thus first call RegisterClassEx, providing a WNDCLASSEX structure containing your class name. The most values of WNDCLASS struct can be filled by calling GetClassInfo.
WNDCLASS wndcls;
memset(&wndcls, 0, sizeof(WNDCLASS));
::GetClassInfo(AfxGetInstanceHandle(),"AfxFrameOrView",&wndcls);
wndcls.lpszClassName = "MyNewClass";
::RegisterClass(&wndcls);
After that steps your class name is made known by the system and can be used.
|
|
|
|
|
In my application, i have a sub frame window derived from CMDIFrameWnd that is NOT the main frame of the application. I need to be able to add Child frames from a specific document template to this frame. Any ideas on how i might go about doing that?
He's fetching hot.
|
|
|
|
|
hi all,
does anybody know how a CImage bitmap can be outputted to a dialog window? I want to use CImage because i have direct access to setpixel commands.
thanks,
Paul.
|
|
|
|
|
What is CImage ? Is that the Image class in GDI+ ? Just create a Graphics object to contain the dialogs HDC and draw the image onto it.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
hi,
by default using a tree control, if i don't declare on_wm_keydown() in my message map, the treectrl uses its own predefinied actions for the keydown operatiosn.. is it possible to use the predefined keydown operation with the ones that i implemented myself at the same time? ie, if keydown message is vk_up and vk_down, i want to use the default treectrl operation(moving the focus of a node in the tree up and down). if keydown message is vk_insert, i want to use my own function.. is it possible? thanx in advance..
|
|
|
|
|
Yes! Simply check for VK_INSERT. If it happens, do your stuff; otherwise, call the base class's OnKeyDown.
Regards,
Alvaro
All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain
|
|
|
|
|
I have a database where one of the columns is a DECIMAL type. Are there any functions in the C runtime library or Windows API for working with this type directly?
|
|
|
|
|
AFAIK it's just a float
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Anders Molin wrote:
AFAIK it's just a float
or even better: double
If you need to extract it from a string, just do:
double MyData = atof(szMyTextData);
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I feel kinda stupid asking this... but when I try creating my edit box I can't get it to look 3D!!!
The font that the edit box has is damn ugly too!
How to get away from these things!?
I never had these problems when I did the same on VC++ 6! Now I'm using Vc++ 7
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Set the font to the parent's font.
pYourEdit->SetFont(pYourEdit->GetParent()->GetFont());
or just simply:
pYourEdit->SetFont(GetFont());
, if you are doing it from the code of parent's window.
Zolee
|
|
|
|
|
Sorry I didn't tell you that I don't use MFC!
I create my edit box like this:
wndCmdEdit = CreateWindow("edit",
NULL,
WS_CHILD | WS_VISIBLE |
WS_BORDER | ES_LEFT | ES_MULTILINE,
5, 130,
385, 20,
hWnd,
(HMENU)IDC_MAINWNDEDIT,
hInst,
NULL);
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
For 3D look, use the CreateWindowEx() function with the WS_EX_CLIENTEDGE extended window style. Then use SendMessage() to send a WM_SETFONT message to the edit control to set it's font.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|