|
I do it like this ...
ServerFunc(LPDISPATCH *p)<br />
{<br />
CMyClass object;
LPDISPATCH lpDisp = object.GetIdispatch(TRUE);
*p = lpDisp;<br />
}<br />
<br />
<br />
#include "server.h"
void foo()<br />
{<br />
LPDISPATCH *lpDisp<br />
ServerFunc( &lpDisp );<br />
IMyClass *pMyClass = new IMyClass(lpDisp);<br />
}
It works for me
|
|
|
|
|
The problem for me is: ServerFunc runs in a different Process, so I just can't pass the IDispatch * this way.
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
I am trying to access the StudentTable in an Oracle database, I have set the data source correctly. There is also no errors reported
after I built the exe file. but when I ran the exe, I can see the messagebox showing the "connectinon to the database succeeds." In the following step, there is
a messagebox with title "Microsoft Visual C++ Runtime Library" showing "Runtime error ...".
I don't know where is wrong , here is the code, who could tell me where is wrong? Thanks.
BOOL flag=FALSE;
flag=m_db.Open("MyDSN",FALSE,FALSE,"ODBC;UID=user1;PWD=userpwd",TRUE); //m_db is a CDatabase member object.
if(flag)
AfxMessageBox("connectinon to the database succeeds.");
else
AfxMessageBox("connectinon to the database failed.");
CRecordset rs(&m_db);
try
{
if(rs.IsOpen())
rs.Close();
if(rs.Open(AFX_DB_USE_DEFAULT_TYPE,_T("select * from user1.StudentTable"),CRecordset::readOnly))
AfxMessageBox("Recordset has been opened!");
}
catch(CDBException e)
{
e.ReportError();
AfxMessageBox("Failed to open the recordset");
}
|
|
|
|
|
Have you single-stepped through the code to see which statement is causing the error?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
I am writing software that parses out an RTF file. One of the things I want to do is extract pictures and save them to a file. The following is taken directly from Microsoft's RTF FAQ (version 1.3):
---- From RTF FAQ ---
The picture in hexadecimal or binary format follows the picture-destination control words. The following example illustrates the destination format:
{\pict\wbitmap0\picw170\pich77\wbmbitspixel1\wbmplanes1\wbmwidthbytes22
\picwgoal505
\pichgoal221
\picscalex172
\picscaley172
49f2000000000273023d1101a030
3901000a000000000273023d98
0048000200000275
02040000200010275023e000000000
273023d000002b90002b90002
b90002b90002b9
0002b90002b90002b90002b90002b90002
b92222b90002b90002b90
002b90002b9
0002b90002b90002b90002b9000
---- End of Stuff from RTF FAQ ---
I am able to parse out all of the bytes (in this example, beginning 49f2...) and I convert them from their text representation to real bytes (i.e., the character sequence "49" is converted to 0x49), but what I get is not a readable picture.
Here is more detail: Suppose I have a bitmap file. I take the same picture and embed it in an RTF document. I can open up the document in Notepad and view the hexidecimal represeantion of the image. I have also written a program that can read a binary file such as a bitmap and convert it to the text equivalent of a hexidecimal as it would appear embedded in the RTF document. I then visually compare the hex I generated directly from the hex embeded in the RTF file.
The hex from the RTF file is the same as the hex I generate directly from the disk file... EXCEPT for the first several hundred bytes! Each source starts out different, but after a hundred byts or so, each is then the same, so I know my encode/decode should be working.
But why is the hexidecimal of the embedded picture not exactly the same as the hexidecmal of the disk file? According to the RTF FAQ, they should be. What can I do to extract the picture? Did Microsoft do something to encode the first series of bytes for a picture so that no one else can extract it?
I have found this problem with both bitmaps and GIF files. I am using MS Word 95 to generate the RTF files with pictures embedded.
|
|
|
|
|
I don't know the answer, but from your question, it sounds like some picture header is being modified. I'd look for specs for your picture format, and manually compare the hex. It wouldn't surprize me if Word was changing something in the headers, but you can't know unless you start reading.
Have your tried other programs that read rtf? There are some free ones. (Open Office comes to mind). Perhaps there is a bug in word95, or it isn't implimenting the same version of rtf as what you are working on.
If you are encoding, can word read your document? How about other programs. If you just want to decode, save some pictures in rtf, decode, and see if they look the same.
Don't forget to extract your pictures with Word again (if you can) to see if it saves the same thing as the origional.
The way you worded your question I suspect your program is working correctly. If your pictures look the same visually, I wouldn't worry about it. If there are visual differences, you are on the right track to solving them.
|
|
|
|
|
I believe that it's a OLE Stream that embeds the picture, not a straight picture.
--
Joel Lucsy
|
|
|
|
|
Hi everybody.
I'm looking for a nice algo which I can use for parsing audio-files and extracting tags. The algo should have the possibility to define the structure of the filenames via a mask and wildcards. Several programmes make use of such a method, for example Tag&Rename: http://iserver.hta.fhz.ch/~iasummer/stuff/tagrename.gif
I haven't found a good and free avaiable source code for parsing files like that, so any links or general information would be great!
|
|
|
|
|
Are you wanting a masked edit control, or are you wanting to find files based on special characters (in addition to "*" and "?" which are already supported).
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
me think he want to do the following :
for a filename like
"01-Pink Floyd-The Dark Side Of The Moog-Money.mp3"
he wants to extract the song number, artist, album and track name.
basically, a sscan.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote:
basically, a sscan.
I assume you mean sscanf() . If so, then something like the following would work:
char *lp = "01-Pink Floyd-The Dark Side Of The Moog-Money.mp3",
szNumber[8], szArtist[16], szAlbum[32], szTrack[16];
sscanf(lp, "%[0-9]%*c%[^-]%*c%[^-]%*c%[^.]", szNumber, szArtist, szAlbum, szTrack);
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
Yeah, sscanf looks like the thing I need. I have to write a programme where the user can specify the structure of a file to get the tags from the filename.
E.g. if you have an MP3 Files with the structure like this:
"01-Pink Floyd-Dark Side Of The Moon_SPEAK TO ME.mp3"
"02-Pink Floyd-Dark Side Of The Moon_breathe in the air.mp3"
The user should have the possibility to enter the mask like this
%t-%a_%s (or <track />-<album>_<song>)
the programme should now parse the filename and set the params for track album and song. I've seen a mask editor in several programmes (e.g. Tag&Rename). If you could provide me with some more codesamples, that would be great (I'm a newbie to C++).
BTW, In a next step, our programme should analyze the filenames and suggest a mask by itself.
|
|
|
|
|
I have an MFC application where one of the dialogs can have 10 versions of it on display (multiple instances). I use a member variable to control the latest one called up, but would like this variable set to the current one; i.e. if the user clicks on display 2 I would like to make that one the current display.
Currently the varaible is set to the last one created, how do I set it to the current just clicked.
I know I can use:-
this->m_nCurrentDisplay;
but what event or message do I use.
Regards
|
|
|
|
|
how do I set it to the current just clicked.
I assume you are using modeless dialogs ?
you could handle CWnd::OnActivate ( WM_ACTIVATE ) or CWnd::OnSetFocus ( WM_SETFOCUS ) on the dialog, and have a variable in the parent window ( or the class that create the dialogs ) to hold the current dialog pointer ( or hwnd, ... ) .
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I have asked a question to display dropdown menu when button is clicked.You have suggest me Foobar.asp application . I want to convert that button as a toggel type button.When button is clicked once it shows dropdown menu .Next time when it is clicked next time it should be clossed.
And one more thing i need the effect that when one button is clicked it display menu when we move to next button it should display next menu
Learner always
|
|
|
|
|
rver wrote:
You have suggest me Foobar.asp application .
I have?, man, I think I have to cut down on the booze...
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
|
what are the basic setting we have to do in the Microsoft Visual Studio to run this code?
Create a new and empty Win32 Project located in C:\Programs\MSVC Exercises and set its the Name to Messages1
Specify that you want to Use MFC in a Shared DLL
Create a C++ file and name it Exercise
To create a frame for the window, in the Exercise.cpp file, type the following:
#include <afxwin.h>
class CMainFrame : public CFrameWnd
{
public:
CMainFrame ();
protected:
DECLARE_MESSAGE_MAP()
};
CMainFrame::CMainFrame()
{
// Create the window's frame
Create(NULL, "Windows Application", WS_OVERLAPPEDWINDOW,
CRect(120, 100, 700, 480), NULL);
}
class CExerciseApp: public CWinApp
{
public:
BOOL InitInstance();
};
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
END_MESSAGE_MAP()
BOOL CExerciseApp::InitInstance()
{
m_pMainWnd = new CMainFrame ;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
CExerciseApp theApp;
|
|
|
|
|
no particuliar settigns, except that this code must be in a MFC project
TOXCCT >>> GEII power
|
|
|
|
|
Is it just me or has the standard of questions in this forum hit an all-time low?
How do I write a program?
What steps should I take to blow my nose?
Is breathing essential?
Pls heeeeeeeeeellllllllllppp meeeeeeee!!!
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Phil J Pearson wrote:
Is it just me or has the standard of questions in this forum hit an all-time low?
It's just all too easy to throw your question/problem over the fence to see if an answer comes back over. Problem-solving skills seem to be scarce. I see too much of the "As long as it works, I don't need to know how, and if it stops working, I can ask around." mentality.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
"As long as it works, I don't need to know how, and if it stops working, I can ask around." mentality.
Another reason why everyone should study geometry and assembly language, regardless of their field of study.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Sorry if this seems complex (it is!). Please bear with me.
I have an application that calls into a dll. The app is dynamically linked to MFC; the dll is statically linked. Both are MFC71. Rough outline of problem is:
1. App creates a CWnd
2. App calls into dll
3. Dll creates a CWnd (uses AFX_MANAGE_STATE everywhere necessary)
4. App destroys window created in step 1 (it was a splash dialog)
here comes the weirdness...
5. Dll's AfxWndProcDllStatic processes WM_NCDESTROY and ends up calling MFC's OnNcDestroy for the window created in step 3.
6. OnNcDestroy calls PostNcDestroy which does delete this; for the CWnd from step 3.
7. Everything else carries on sweetly until the dll tries to reference data in the CWnd that was vandalised.
Please can someone explain what the ? is happening to cause step 5?
Incidentally, all this happens on the same (main) thread, although other threads do get created elsewhere.
Thanks in advance,
Phil
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|