|
|
Thanks for the tip, but I should have mentioned that I have been compiling with VS 6 with Net Framework 1.1.
Meanwhile I have managed (sort of) with these lines, which do allow me to get the function.
I still fail to see why I have to go through all this, but not for AddFontResource,
and I still have to put 0x10, since FR_PRIVATE is not recognized.
static FARPROC fpAddFontRes,fpRemoveFontRes;
HMODULE hLibrary;
hLibrary=LoadLibraryW(L"gdi32.dll");
fpAddFontRes=GetProcAddress(hLibrary,(LPCSTR)"AddFontResourceExW");
fpRemoveFontRes=GetProcAddress(hLibrary,(LPCSTR)"RemoveFontResourceExW");
.....
nFontLoad=(*fpAddFontRes)(Bact,0x10,0);
At least this works fine !
Raymond Mercier
|
|
|
|
|
RaymondM wrote: Thanks for the tip, but I should have mentioned that I have been compiling with VS 6 with Net Framework 1.1.
My recommendation remains the same. The updated headers are included with the Platform SDK. You can use the Platform SDK with VC6. I have a copy of VC6 installed along-side several versions of the Platform SDK. I can't believe that you went this many years without it.
The LoadLibrary/GetProcAddress technique will also work if you choose to do it that way. But the next time you try to use a new GDI enum/constant or data type you might be back in the same boat.
RaymondM wrote: I still fail to see why I have to go through all this, but not for AddFontResource
AddFontResource[^] was included in the VC6 header distribution. AddFontResourceEx [^]is available in Windows 2000 and above and the header file was updated in the Platform SDK.
The declaration for AddFontResourceEx [^]is preceeded by:
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN2K)
So you would need:
1.) A header file with the AddFontResourceEx declaration.
2.) Declare a windows version greater or equal to _WIN32_WINNT_WIN2K.
Best Wishes,
-David Delaune
modified on Tuesday, January 27, 2009 3:19 AM
|
|
|
|
|
|
RaymondM wrote: I don't know why you think that I do not already have the headers
Because you told me that you were compiling the project with VC6.
RaymondM wrote:
So I only need to add #define _WIN32_WINNT 501 before windows.h, and then I can call the function I need. That is of course the only point that I had overlooked.
Exactly what I stated in my last response. I am happy to hear that you have corrected the problem.
Best Wishes,
-David Delaune
|
|
|
|
|
first, the MSDN about CreateWindow() not mention of close the handle of window it returns.
is it means that we donnot need to care about it?(Sorry about the title if it is true)
second, I test of this in the code like this
HWND hWnd;
unsigned __stdcall SecondThreadFunc( void* pArguments )
{
hWnd = CreateWindow(
L"BUTTON"
,L"dmyWnd"
,WS_DISABLED
,CW_USEDEFAULT
,CW_USEDEFAULT
,0
,0
,NULL
,NULL
,::AfxGetInstanceHandle()
,NULL
);
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
{
if (bRet == -1)
{
TRACE(L"[Thread] ERROR\n");
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}
_beginthreadex( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID );
I try to call
int nRt = ::GetWindowText(hWnd, cs, 256); before and after I
::PostThreadMessage(threadID, WM_QUIT, 0, 0); to end the thread.
The result is sccess when thread alive and invalid handle when thread exit.
I am not sure if this can prove that window handle is be safely closed.Could any one tell me
that is it true "Window Handle from CreateWindow will colse itself when thread exit"
|
|
|
|
|
fitatc wrote: Could any one tell me
that is it true "Window Handle from CreateWindow will colse itself when thread exit"
No, not necessarily - it'll be because the thread's has gone. GetWindowText performs a SendMessage of WM_GETTEXT to the window you want. SendMessage to a window owned by another thread means switching to the thread and calling the window's WndProc. If the thread no longer exists, that's not possible, so the function returns an error.
|
|
|
|
|
To a certain extent windows (HWND s) belong to the thread that created them. For example, the thread that created the window is the thread that pumps its messages. See Thread affinity of user interface objects, part 1: Window handles[^] for deatils. It doesn't make sense to create a window with a thread and then let it outlive its parent thread.
Steve
|
|
|
|
|
Hi,
fitatc wrote:
I am not sure if this can prove that window handle is be safely closed.Could any one tell me
User applications do not manage window handles. To be more specific your application does not create/destroy or manage windows directly. The windows kernel does all of this for you when you request it.
There is a device driver named 'Win32k.sys' which through ntdll.dll creates and manages the window for you. when you make a call to CreateWindow it ultimately passes through VerNtUserCreateWindowEx then ZwUserCreateWindowEx and your window is created. Event messages are then placed in the message que associated with the window. At this point your application can retrieve these messages and react to them.
If you don't understand anything I just said... just remember that you do not need to close window handles.
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you very much, that just the answer what I need!!!
|
|
|
|
|
HI,
I am having a CView which has some controls, i would like my top part(1/3rd portion) of the view to be hidden dynamically when ever i press some button.
How do i go about.
|
|
|
|
|
Hi,
well, I would write a function with
GetDlgItem(IDC_MYCONTROL)->ShowWindow(SW_HIDE); for each of your controls.
That should do what you want.
|
|
|
|
|
HI, thanks for the reply...this would actually just hide the controls, but i would like my bottom part of the view to be shifted to top.....
|
|
|
|
|
Try Splitter windows.. You can get lot of articles in CP..
Selva
|
|
|
|
|
Hi, if your problem is not solved yet have a look at this article[^]
If you combine this with moving your controls with
GetDlgItem(IDC_MYCTRL)->SetWindowPos(); you should be fine.
|
|
|
|
|
Hi,
I want to constuct a data structure with following condition-
The first structure is having 3 element e.g Name1 ,age1 ,roll no1.
The second structure contain the 3 element i.e roll no 1, subject 1
roll no 1, subject 2
roll no 1, subject 3
i.e Roll no may have one or more than one subject associated with it. I want to write a program which will take input as Name,Age, Roll No ,subject(no.of subjects may very).
Then I will take Input from user As Roll No, Query the structure and display name,age and subject/s.
Can you please suggest which data structure (CMAp,CList... etc.) is suatiable for such condition?
Thanks:-
Mike
|
|
|
|
|
Something like:
struct
{
string name;
int age;
int roll;
vector<string> subjects;
};
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
|
need some help to use Ω (ohm Symbol) for display
i-e
CString str="Ω";
MessageBox(str);
but VisualStdio editor Doesnt support to Paste this smybol that is copied from Word file. so how can i use it.
|
|
|
|
|
Try to load the string at runtime, set appropriate font and display it.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
You may write, for instance:
CString str = L"\x03A9";
MessageBox(str);
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]
|
|
|
|
|
CPallini wrote: CString str = L"\x03A9";
MessageBox(str);
Wrong.
should be (if you want the code to compile regardless of the compilation mode) :
CStringW str = L"\x03A9";
MessageBoxW(str);
|
|
|
|
|
I was aware he had UNICODE defined. It's not wrong, given the context.
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]
|
|
|
|
|
It is wrong to make an assumption on the context...
Writing a strong and robust code means writing a code that will compile and run regardless of such an assumption.
So here, you're twiddling a Unicode string, so why not storing it anytime in a Unicode string object (CStringW ) ?
|
|
|
|
|
toxcct wrote: It is wrong to make an assumption on the context...
Shouting will not improve your point.
It is not wrong making assumption about the context: your code is just more general (just a bit: try to compile your context-less code on Linux ). Generic text mapping wasn't for sure the OP's point.
toxcct wrote: Writing a strong and robust code means writing a code that will compile and run regardless of such an assumption.
Again, please don't shout: (thankfully ) you aren't my teacher...
Writing robust code means writing code that will run reliably. Any other statement is 'bla bla bla'.
toxcct wrote: So here, you're twiddling a Unicode string, so why not storing it anytime in a Unicode string object (CStringW) ?
Again, you're right, but it was by no means the obstacle on the OP way, and I'm far from dictating anyone, anytime, the 'good coding guidelines'.
BTW: Have a nice day.
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]
|
|
|
|
|