|
Might anyone know why the following line works in WinXP but not in Win2000
<br />
pMyDocTemplate->OpenDocumentFile( NULL ); <br />
In windows2000 apparently it's telling me there isn't a dialog template.
An interesting note is that, if I create a new document through the toolbar, close the document, then call this method again, it will work. Puzzled by this.
Thanks!
|
|
|
|
|
You're using the same binary on both Windows XP and Windows 2000, and the same version of the MFC DLL?
Is the Windows 2000 system running Service Pack 4? The DLL Help Database[^] indicates that Windows 2000 SP4 shipped a new version, 6.0.9586.0, of mfc42.dll . If you're compiling with MFC 6.0, supplied with Visual Studio 6.0, this might (potentially) be causing the problem. An even newer version, 6.0.9782.0, ships in Visual Studio 6 Service Pack 6.
Exactly what problem occurs? Do you get an ASSERT failure, or an error message? Is the behaviour consistent across Debug and Release builds?
If you get an ASSERT, what source file and line is listed? If you get an error, what is the exact error message?
[edit] Are you using a CSingleDocTemplate , a CMultiDocTemplate , or your own class derived either from one of those or directly from CDocTemplate ? [/edit]
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi, I have some functions written in C# I want to use in Win32 API program (C++ used).
How can I do it. If someone can give me a sample code or direct to the some tutorial.
Thanks
|
|
|
|
|
The 'easy' way - use the regasm tool to export the C# class to COM. Use COM to load the C# code and call it.
The harder way - decompile your C# code with ildasm , add the appropriate declarations to the IL to get the CLR to generate flat exports (as in a traditional C DLL) and recompile with ilasm .
The really hard way - investigate the CLR hosting interfaces.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
|
Does anyone know whether it's possible to recognize right clicks with the CButtonST class developed by Davide Calabro? I know that you can declare a function
afx_msg void OnButton(UNIT nID)
in order to handle left-clicking a button, but can a similar process be applied for a right click? If anyone knows how to do this, please let me know.
~David
|
|
|
|
|
Is there a way that you can attach a command-line parameter on the end of an url? I want to send someone a hyperlink that will open up an .exe - that part works fine, but I also want them to be able to send 2 parameters, (the name of two text files). Is there any way to do that?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
just append the variables to the end of the URL. THey will be ignored if not needed.
so if the URL is "http://this.com/that.exe" just change it to "http://this.com/that.exe?VAR1=foo.txt&VAR2=bar.txt"
Glano perictu com sahni delorin!
|
|
|
|
|
thanks, but are VAR1 and VAR2 going to be automatically recognized?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
my aim is to create a key board driver, i got a program from the net and it is working but i have to focus the the keyboard events to a desired window (say ms word). what changes should i make in the following codes.
#include "mian.h"
#define MAX_COUNT 50 // Max number of keystrokes to remember
#pragma data_seg(".shared") // ".shared" is defined in exports.def to allow
// all instances of the dll to share these variables
HWND m_hHwndKey = 0;
HHOOK m_hHookKey = 0;
HWND m_hHwndMouse = 0;
HHOOK m_hHookMouse = 0;
CHAR m_szMain[MAX_COUNT] = ""; // A buffer to store decoded keyboard codes
int m_nLastPos = 0; // Last position used in the buffer
HCURSOR m_hCursorLast = 0; // These two values are used to copy the mouse
HCURSOR m_hCursorLastRet = 0; // cursor
#pragma data_seg()
// Set the values for the window and hook for the Keyboard hook
void WINAPI SetValuesKey(HWND hWnd, HHOOK hk) {
Sleep(0);
m_hHwndKey = hWnd;
m_hHookKey = hk;
}
// Set the values for the window and hook for the mouse hook
void WINAPI SetValuesMouse(HWND hWnd, HHOOK hk) {
Sleep(0);
m_hHwndMouse = hWnd;
m_hHookMouse = hk;
}
// This is the mouse hook itself
LRESULT CALLBACK MouseProc( int nCode, WPARAM wParam, LPARAM lParam ) {
Sleep(0);
if (nCode < 0) {
return CallNextHookEx(m_hHookMouse, nCode, wParam, lParam);
}
Sleep(0);
if (nCode == HC_ACTION) {
HCURSOR hCursor = GetCursor();
// Copy the mouse cursor
if (hCursor != m_hCursorLastRet) {
if (m_hCursorLast) {
DestroyCursor(m_hCursorLast);
}
ICONINFO ii;
GetIconInfo(hCursor, &ii);
m_hCursorLast = CreateIconIndirect(&ii);
DeleteObject(ii.hbmMask);
DeleteObject(ii.hbmColor);
Sleep(0);
m_hCursorLastRet = hCursor;
Sleep(0);
}
// If the message is a WM_NC*, convert it to a WM_*
if ((wParam >= 0xA0) & (wParam <= 0xA9)) {
wParam = wParam + 352;
}
// Let the listening window know about the message
Sleep(0);
PostMessage(m_hHwndMouse, wParam, 0, MAKEWPARAM(
( (MOUSEHOOKSTRUCT*) lParam )->pt.x,
( (MOUSEHOOKSTRUCT*) lParam )->pt.y));
}
return 0;
}
// Function to get the last mouse cursor that was copied. The return cursor
// is a copy of the copy, so the callee must delete it.
HCURSOR WINAPI GetLastCursor() {
Sleep(0);
HCURSOR hCursor = m_hCursorLast;
m_hCursorLast = 0;
return (hCursor);
}
// Returns the current state of the keyboard bufffer
void WINAPI GetKeyInfo(CHAR * szIn, int * nLastPos) {
Sleep(0);
memcpy(szIn, &m_szMain, MAX_COUNT);
(* nLastPos) = m_nLastPos;
}
// Keyboard hook
LRESULT CALLBACK KeyProc( int nCode, WPARAM wParam, LPARAM lParam ) {
if (nCode < 0) {
Sleep(0);
return CallNextHookEx(m_hHookKey, nCode, wParam, lParam);
}
Sleep(0);
if (nCode == HC_ACTION) {
if (lParam & 0x80000000) {
Sleep(0);
PostMessage(m_hHwndKey, WM_KEYUP, wParam, lParam);
} else {
BYTE lpKeyState[256];
GetKeyboardState((unsigned char *)&lpKeyState);
// Convert the message to a normal keystroke, and store it
// in the buffer
WORD lpChar;
int nRet = ToAscii(
wParam,
(lParam & 0xFF0000) >> 16,
(unsigned char *)&lpKeyState,
&lpChar,
0);
if (nRet == 1) {
m_szMain[m_nLastPos] = (char) lpChar;
m_nLastPos ++;
if (m_nLastPos >= MAX_COUNT) {
m_nLastPos = 0;
}
}
Sleep(0);
PostMessage(m_hHwndKey, WM_KEYDOWN, wParam, lParam);
}
}
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID) {
Sleep(0);
if (fdwReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hinstDLL);
}
Sleep(0);
return TRUE;
}
// This is to prevent the CRT from loading, thus making this a smaller
// and faster dll.
extern "C" BOOL __stdcall _DllMainCRTStartup( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
Sleep(0);
return DllMain( hinstDLL, fdwReason, lpvReserved );
}
|
|
|
|
|
A while back I read something telling me that there was a way to call a base class function from the child class; does anyone know how to do this? Thanks!!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Baseclass::function
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
duh, thanks!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
or simply function() if the child class do not have a function with the same name where the base class declare this function to be virtual...
TOXCCT >>> GEII power
|
|
|
|
|
What's the best way to write HTML code to a file? Is it simply to write the raw tags or are there some libraries around that simply this? Thanks in advance.
- Aaron
|
|
|
|
|
Just write tags like if you were writing some kind of text. save it as you would do with a text file. is the same, but put the .htm extension.
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
<font style="color:blue;">void </font>life (<font style="color:blue;">bool </font>me, <font style="color:blue;">bool </font>her) {
<font style="color:blue;">if </font>(her) {
me = <font style="color:blue;">true</font>;
}
<font style="color:blue;"></font>else {
me = <font style="color:blue;">false</font>;
}
}
wouldn't you prefer declare me as a bool& or even a bool* instead ?
TOXCCT >>> GEII power
|
|
|
|
|
cool comment !!,
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
Depend on his religoius philosophy; whether me destructs when leaving life's scope. (That's almost nausiatingly poetic in a nerdy sort of way. Don't think of it as dying, think of it as going out of scope.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
|
As a bool , it consumes 1 byte. As a bool* , it would consume 4 bytes. Correct? If so, future posts would therefore be 300% larger than necessary!
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
ok for the bool* , but that was an expectation for getting me out of the scope. but what about a bool& ?
TOXCCT >>> GEII power
|
|
|
|
|
Michael Dunn told me "Use the CCS_NOPARENTALIGN style".
I've used it but what I win with this is that I can set up the height free, but I am not able to put 30 pixels from left for example. I use this function to call the CToolBarCtrl:
my_tool_bar.Create(WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_NOPARENTALIGN, CRect(0, 110, 80, 80), this, IDC_MY_TOOL_BAR);
If I set up like this:
my_tool_bar.Create(WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_NOPARENTALIGN, CRect(30, 110, 80, 80), this, IDC_MY_TOOL_BAR);
The top fails... I don't know what to do...
Please, if you could put me an example of how to create a CToolBarCtrl with no top or bottom alignment into the window... I want to draw it into a CRect from the Window.
Thanks in advance !!!
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
Well, I solved it:
my_tool_bar.Create(WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_NOPARENTALIGN|CBRS_NOALIGN|CBRS_FLYBY, CRect(30, 110, 80, 80), this, IDC_MY_TOOL_BAR);
Thanx anyway !!
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
Hi all! I had a question concerning visual c++ 6.0. I'm coding a card game in Win32 (no MFC) and am trying to fill an edit box on a dialog window dynamically with child controls. What the program does is it queries the current directory for all sound (.wav) files and, for each sound file, inserts three child controls in the edit box on one line. The controls are, from left to right, an edit box for the caption the user wants for this sound file, a play button to listen to the sound, and a second edit box for the name of the sound file.
I'm inserting these into an edit box because, since the sound list is obviously dynamic and of arbitrary length, I'd like to utilize the scroll bar on the edit box. The problem I'm running into is that the edit box is unaware of anything being added to it. I'm calling CreateWindow to add these controls to the edit box, with the handle to the edit box as the parent parameter, and the lines of child controls for the sound files fill up past the depth of the edit box without the scroll bar being activated.
One solution I tried was to insert a newline character into the edit box for each line of controls I added. This solved the scroll bar problem, but when you scroll the edit box the display gets really confused as to what to display (the controls or the "\n").
Any advice is GREATLY appreciated.
Carl Scafidi
|
|
|
|
|