|
One fairly easy solution is just to draw your text 4 times in black, offset by one pixel in each direction, then once in your desired colour in the middle
i.e.
Text( x-1,y, "Hello", BLACK )
Text( x+1,y, "Hello", BLACK )
Text( x,y-1, "Hello", BLACK )
Text( x,y+1, "Hello", BLACK )
Text( x,y, "Hello", WHITE )
or you could just use a for loop if you want a thicker border
Obviously this all relies on your text rendering code being nice and fast, but if you're using anything modern then it should be
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
I'm working in C and would like to be able to use the SHBrowseForFolder to have a folder browser. I used the following code:
void FolderDialog(HWND hDlg, int msgField)
{
IMalloc * pMalloc;
if ( SHGetMalloc(&pMalloc) == NOERROR )
{
BROWSEINFO bi;
char pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
bi.hwndOwner = hDlg;
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = "Select Directory";
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
if ((pidl = SHBrowseForFolder(&bi)) != NULL)
{
if (SHGetPathFromIDList(pidl, pszBuffer))
{
SetDlgItemText(hDlg, msgField, pszBuffer);
}
pMalloc->Free(pidl);
}
pMalloc->Release();
}
}
I get the following two errors:
error C2039: 'Free' : is not a member of 'IMalloc'
(846) : see declaration of 'IMalloc'
error C2039: 'Release' : is not a member of 'IMalloc'
(846) : see declaration of 'IMalloc'
If I remove the Free and Release statements the program execute fine but I would rather not have that kinda leakage going on. Any suggestions would be much appreciated.
Thanks
|
|
|
|
|
Use the vtable explicitly.
pMalloc->lpVtbl->Free()
The price you will pay for skipping ++
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
Stefan,
I did something similar earlier but now I get the following errors:
error C2198: 'function through pointer' : too few actual parameters
error C2198: 'function through pointer' : too few actual parameters
Believe me I would have much rather done this in civilized code but its not my call.
Thanks
|
|
|
|
|
Ok Stefan,
You were right, sorry about the hassle. I found the explanation to my question here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/intro/program/com/usingc.asp
Should have researched more before I opened my mouth.
Basically using COM with C requires an extra level of indirection + an additional parameter which points to the interface...
so in my case, this works:
pMalloc->lpVtbl->Free(pMalloc,pidl);
}
pMalloc->lpVtbl->Release(pMalloc);
Thank you much
Nadim
|
|
|
|
|
THis is an MFC MDI app. I get the msgBox for :
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
CResizeSonarViewBoxView *pView = (CResizeSonarViewBoxView *) pChild->GetActiveView();
if(pView == NULL)<code>AfxMessageBox("Null pView")</code>;
I only have the one view so far. Whats is wrong and how do I fix it?
ACtually how do I go about tracking down this problem?
Thanks
Appreciate your help,
ns
|
|
|
|
|
Hello,
For MDI you have to do it another way....
<br />
CView * SomeClass::GetActiveView(void)<br />
{<br />
POSITION pos;<br />
CMDIChildWnd *pChild;<br />
CDocument *pDoc;<br />
CView* pView;<br />
CMainFrame *pFrame;<br />
<br />
pFrame = (CMainFrame *) AfxGetMainWnd();<br />
ASSERT(pFrame!=NULL);<br />
pChild = pFrame->MDIGetActive();<br />
ASSERT(pChild != NULL);<br />
pDoc = pChild->GetActiveDocument();<br />
ASSERT(pDoc != NULL);<br />
pos = pDoc->GetFirstViewPosition();<br />
ASSERT(pos != NULL);<br />
pView = pDoc->GetNextView(pos); <br />
return pView;<br />
}<br />
Hope that helps,
Paul...
|
|
|
|
|
I see what you are doing. But the sample I have trouble withis actually from a working program that I put together last year..............it works great there! I wonder why.
I'll do your method in this project though I am very very puzzled!
Appreciate your help,
ns
|
|
|
|
|
The one thing that might be the problem is that my old project where the code I posted, has two views. In this curent code I only have 1 view.....Could that be the problem?
Appreciate your help,
ns
|
|
|
|
|
Crashed at the assert:
POSITION pos;
CMDIChildWnd *pChild;
CDocument *pDoc;
CResizeSonarViewBoxView* pView;
CMainFrame *pFrame;
pFrame = (CMainFrame *) AfxGetMainWnd();
ASSERT(pFrame!=NULL);
pChild = pFrame->MDIGetActive();
<code>ASSERT</code>(pChild != NULL);
Thanks
Appreciate your help,
ns
|
|
|
|
|
Hi,
What happened to the..
pDoc->GetFirstViewPosition();<br />
part of the code???
|
|
|
|
|
Crashed before it got there! Thtas why Ididnt paste that part....
Appreciate your help,
ns
|
|
|
|
|
Hi all,
I've written a function that finds the top window, botttom window, and next highest window (in terms of z-order). It then takes the top window, places it behind the bottom window, and make the next highest active. This works for everything except MS Office windows. For some reason, MS Office apps always end up being placed behind the next highest window, which means when cycling through the windows, they show up as evey other window.
I'm using GetWindow in a loop in the function, and according the MSDN, it recommends using EnumChildWindows instead of GetWindow in a loop. Is there a function that I can use in the EnumChildProc that will return a value for the z-order of the window (or is there a better way to do this)?
Thanx!
Chris
|
|
|
|
|
Hello,
Just wondering if anyone has any neat tricks to give users an option to have your software startup when windows loads (or not startup)..
Any ideas?
Rob
|
|
|
|
|
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
|
|
|
|
|
We have a rather large touch panel interface design application that was not originally designed for or compiled with the _UNICODE compiler flag. We have need now to be able to accept Unicode character input (either via foreign keyboard/OS, or by IME, or by clipboard) in a single specific edit control (which is currently a CEdit object).
I've done considerable amounts of research and testing into overriding window procs and message pumps in an attempt to receive WM_CHAR messages as Unicode character codes, but have not achieved 100% success (i.e., some characters come though as Unicode, but others still come through as the familiar '?'/0x3F character).
Any insight or tips & tricks to pull this off would be greatly appreciated, as we are willing to try just about anything to avoid having to recompile as a Unicode application and deal with the time and headaches involved with the conversion and with linking with external LIBs and DLLs.
As always, thanks in advance.
Rob Whapham
Managing Software Engineer
AMX, Corp.
http://www.amx.com/
|
|
|
|
|
I want to embed the WebBrowser control in my application, and I want to add custom protocol handling. I figured I just host the protocol handler in my application and register it on app-startup.
However, it looks like the protocol registration is global, and hence any other running instance of IE open while my application is open will use the same handler.
Is there some way to register handlers for a specific instance of the browser? Or do I just get to put up with this "added feature"?
J
May the bear never have cause to eat you.
|
|
|
|
|
Hello everybody
I have a normal combobox in a dialog, and besides the initial items loaded from a file I want the item shown in the editbox area of the combobox to be automatically updated when the user writes something inside it. I also wuld like this string to be "stored", so that next time he/she pulls down the combobox this string is still there.
I actually tried to implement notification handlers for: ON_CBN_SELENDOK , ON_CBN_EDITCHANGE and ON_CBN_EDITUPDATE but I couldn't exactly get what i need.
Any info/tip will be greatly appreciated
thank you
best regards
|
|
|
|
|
You want the program to add new items to the combobox as the user types in text?
For example:
EditBox: January
ComboBox:
J
Ja
Jan
Janu
Janua
Januar
January
Is that what you mean? Window should send ON_CBN_EDITCHANGE as the user makes changes to the editbox. Add new items accordingly.
Kuphryn
|
|
|
|
|
Hello, thank you
with reference to your example i'd wish adding just only 'January', I mean when the user has entered a new complete item
thanks again for any tip
best regards
|
|
|
|
|
One solution is to process the data in real-time. Thus each time the user makes a change, you analyze the text and process it accordingly.
Kuphryn
|
|
|
|
|
Hello,
I am in need of a NON MFC sample project or code fragment that accesses a non-windowed ActiveX control. i.e., a control that doesn't have a GUI aspect to it like MSCOMM. After doing searches here and on MSDN, the only posts I've found suggest not to use the Win32 SDK, but to use MFC. In this instance, that is not an option. However, if there is an article that can be used to convince the customer otherwise and use MFC, that would be better. Right now they want to use the Win32 SDK with one of our ActiveX controls.
Any help would be appreciated.
Regards,
Paul...
|
|
|
|
|
use #import. It only includes <comdef.h> and not other ATL/MFC.
|
|
|
|
|
Thanks for the suggestion, but it doesn't explain much to me.
Here is the call to the Create function of the control:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName,<br />
DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID,<br />
CCreateContext* pContext = NULL)
What is used for the CWnd* parameter since the parent will get event messages?
Do you have an example of how #import can be used for the call above?
|
|
|
|
|
I am confused "..NON MFC sample ..." "...non-windowed ActiveX..." "...that doesn't have a GUI aspect...".
In the sample above, you are creating window(1) and using MFC(2) for it. It kind of does not match the original requirement .
What I was proposing is following
in stdafx.h (or main.h or whatever.h file you are using)
#import "libid:12345" no_namespace //12345 being libid of your control
in your code.cpp
void somefunction()
{
//Note: IYourControlMainInterfacePtr and
//YourControlsCoClass generated by #import
IYourControlMainInterfacePtr spMain(__uuidof(YourControlsCoClass));
spMain->SomeMethodOnTheControl();
.....
}
|
|
|
|