|
Joaquín is right. If you declare the dialog members as static to change them from __thiscall to __cdecl , then something like this will work:
#include <iostream>
#include <windows.h>
using namespace std;
typedef BOOL (*POPULATEPROC) ( char* pbuffer, USHORT data );
class CIWishIWasADialog {
public:
CIWishIWasADialog();
~CIWishIWasADialog();
static BOOL Populate_Devicename( char* pbuffer, USHORT data ) {
cout << "We're in Populate_Devicename - " << pbuffer << endl;
return TRUE;
}
static BOOL Populate_Modelname( char* pbuffer, USHORT data ) {
cout << "We're in Populate_Modelname - " << pbuffer << endl;
return TRUE;
}
};
struct FIELD_DATA
{
CHAR name[40];
USHORT width;
POPULATEPROC popproc;
};
FIELD_DATA My_Data[] = {{"Device Name", 20, CIWishIWasADialog::Populate_Devicename},
{"Model Name", 25, CIWishIWasADialog::Populate_Modelname }};
int main(int argc, char* argv[])
{
My_Data[0].popproc("Honda",0);
My_Data[1].popproc("Accord",0);
{
int x;
cin >> x;
}
return 0;
}
But now you have a bit of a problem in that the static members don't have access to other members (i.e. don't have an implicit this pointer).
Hmmm... what if you had a series of windows messages defined - like UWM_POPULATE_MODELNAME - then you could post a message to the dialog instead of calling a member directly. You could then just use the message IDs in your structs as well, and wouldn't have to worry about the dialog::function name.
|
|
|
|
|
Thanks for the info, I managed to get it to work using the C++ Faq idea..
Created a static function, I passed "this" in as one of the params, then casted it to the dlgtype... works.
Much appreciated.
Mike.
|
|
|
|
|
Lame.
I'm trying to use ShGetFolderPath to figure out the location of the "My Documents" forlder and MSDN claims that I need ShFolder.h and ShFolder.lib. Overlooking the fact that all other shell related files begin with "SHL" and not just "SH", when I included them, my compiler (VC6 no SPs) claims not to be able to locate them...
I looked for them myself and lo and behold, they are missing. I seem to have every other file, just not the one I want.
So, I have two questions:
1. Do the ShFolder.* files exist and for some god-foraken reason I don't have them or are they part of mythology?
2. Is there another API or way to find the "My Documents" folder that does not include searching the hard drive for it?
Thanks in advance,
The Arabundi
---
PAGE FAULT: Please insert "Swap File Disk 2" in drive and press any key to continue
|
|
|
|
|
Hello, the codegurus around the world.;)
Probably, you need Microsoft Platform SDK.
I checked ShFolder.h in include of MPSDK, and to be sure, it has.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Thank you
---
PAGE FAULT: Please insert "Swap File Disk 2" in drive and press any key to continue
|
|
|
|
|
Hi to anyone,
I've a some problems on using ReadFile and WriteFile API functions.
I'm usinge these API on a function that will merge multiple files into one file.
The problem is that any nul(0x00) character will be converted (after WriteFile() call) to sp(0x20).
I've used a 'BYTE buf[4096]' buffer to load into datas and also changed this buffer to an 'LPVOID lpbuf' dinamicaly allocated with (HeapAlloc() function), but never changed.
Can anyone tell me my these conversions?
What I'm doing so wrong?
thank you in advance.
"Take time to think, it is the source of power"
|
|
|
|
|
I believe you have to open the FILE stream as binary.(if you are not all ready doing that) That way everything is treated as raw binary data.
erik
|
|
|
|
|
Correct, but I opens all files with CreateFile(...) API call.
How can I specify binary mode instead of text mode?
Thank you in advance
"Take time to think, it is the source of power"
|
|
|
|
|
Excuse me, but I've solved my problem.
I was causing the conversion with my code.
Thanks for your time
max
"Take time to think, it is the source of power"
|
|
|
|
|
This is a question relating to Windows CE 3.0
What I would like to know,is there a way to get rid of the OK and Close buttons that get put on the title bar of a Property sheet.
Any help would be apprectiated.
|
|
|
|
|
Can anyone help me with this. I am trying to compile a Debug multithreaded DLL and I keep getting the following errors. I am really stuck so if anyone has encountered these errors before and can point me in the right direction I would greatly appreciate it.
nafxcwd.lib(timecore.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
Debug/if_boxcube.dll : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
if_boxcube.dll - 6 error(s), 0 warning(s)
Thanks, In Advance
Stacie
"Imagination Is More Important Than Knowledge" ~Albert Einstein
|
|
|
|
|
Did you manage to fix this? I'm having the same problem.
James Spibey
I love the word naked, it's brilliant isn't it, 'naked'. When I was a kid I used to write the word naked on a bit of paper hundreds of times and rub my face in it - Jeff, Coupling, BBC2
|
|
|
|
|
Hello, the codegurus around the world.;)
I wrote the code to eject the cd from my application.
First time, I use mciSendString () to do this, and this works fine.
But, QA pointed out that this code didn't work on Windows 95 and NT without installing
MCI.
So, I use DeviceIoControl function since I found some sample code for Windows 9x and NT.
However, since I'm lazy , I omitted the code to check if the other application
uses CD or lock and unlock CD.
Without these codes, my code works fine on Windows OS including Windows XP.
But, I'm curious that we need these kind of codes - check if the application uses CD or lock or unlock CD.
(In fact, the time of executing my code rarely faces these kinds of situation, so I omitted these.)
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
How to add control on the CProperty Page .
|
|
|
|
|
Add a new resource. (Insert->Resource->Dialog->Property Page)
Create the property page as you would any standard dialog.
When you create a class for the new resource, make sure you derive from CPropertyPage. That's it.
|
|
|
|
|
Not for the faint hearted. I recently changed the way my project was designed and parts of it stopped working, I tracked this down to a media com object being created in my worker thread and not the thread where my *mainframe* window resides.
Question?
If I'm in a worker thread is there anyway to create a com object under the context of another thread i.e the thread where my mainframe resides, I'm sure I've done this before, but have'nt touched COM for 6months.
Thanks In Advance
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
Does the com object work in a worker thread (does it have a window or need a message pump)? You may need to create it in your main thread or a user-interface thread instead.
If you create a com object from the worker thread, then it cannot be called from other threads directly because the com implemenation uses windows messages to call objects in other threads.
|
|
|
|
|
Here goes, hope this is clean
[CMainframe]
|
+-W A S----> OnTimer
| new ATLMediaPlayerWrapperWnd *This Worked*
|
+ N O W----> ActionThread (Responsible for creating objects etc)
| new ATLMediaPlayerWrapperWnd *This Doesn't play but screen a single frame*
if I put DoEvents( PeekMessage etc) in the while (1) loop is works fine.
Ideally I *dont* the DoEvents code, the the object needs to be create in the ActionThread code.
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
if I put DoEvents( PeekMessage etc) in the while (1) loop is works fine.
That means you DO need to have a message pump for the object to work. Why not change the ActionThread to a user interface thread derived from CWinThread so that you don't need to DoEvents explicitly.
|
|
|
|
|
Owwww noooo, can't do that. Need especially CWinThread (horrid) need to keep the object in a worker thread. I think I have a solution see other postings on this thread.
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
"Owwww noooo, can't do that. Need especially CWinThread (horrid) need to keep the object in a worker thread. I think I have a solution see other postings on this thread."
Good for you. Comeback when it doesn't work.
|
|
|
|
|
Got it working, do you won't a copy for reference
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
No, thanks. But you did move the creation of your com object to the main thread which has a message pump, right?
Otherwise, you need to write an article to explain how it is working.
|
|
|
|
|
You can create the object and then marshal it to the other thread via CoMarshalInterThreadInterfaceInStream.
|
|
|
|
|
I know where your coming I reckon this should do the trick?
CMyActionThread::CreateObject()
{
SendMessage(m_hWnd, WM_CREATE_OBJECT, 0, 0);
//
Now get the marshedPointer!
}
LRESULT CMainFrame::OnMyCreateObjectMessage(WPARAM wParam, LPARAM lParam)
{
// Create the object
// Marshal the object
return 0;
}
and it's coming back now, in essential com, there's helper functions, WritePtrToGlobalVariable and ReadPtrFromGlobalVariable
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|