|
Hello,
Does anyone know how to call a fortran dll in MS VC?
I need some help calling one.I compiled the file below. Added the .lib file to the link tab. But I get this error.
Linking...
debug/DLL_ROUT.lib : fatal error LNK1106: invalid file or disk full: cannot seek to 0x3e218d3c
Error executing link.exe.
DLL_ROUT_EXE.exe - 1 error(s), 0 warning(s)
Fortram file is below.
<br />
! Fortran part of a C-Fortran DLL example. This<br />
! routine DLL_ROUT is called from a C executable program.<br />
SUBROUTINE DLL_ROUT (INT_ARG, STR_IN, STR_OUT)<br />
IMPLICIT NONE<br />
<br />
! Specify that DLL_ROUT is exported to a DLL<br />
!DEC$ ATTRIBUTES DLLEXPORT :: DLL_ROUT<br />
<br />
INTEGER INT_ARG<br />
CHARACTER*(*) STR_IN, STR_OUT<br />
<br />
! This routine converts INT_ARG to a decimal string.<br />
! appends the string value to STR_IN and stores it<br />
! in STR_OUT. A trailing NUL is added to keep C<br />
! happy.<br />
!<br />
! Note that there are implicit length arguments following<br />
! the addresses of each CHARACTER argument.<br />
<br />
CHARACTER*5 INT_STR<br />
<br />
WRITE (INT_STR,'(I5.5)')INT_ARG<br />
<br />
STR_OUT = STR_IN
<br />
RETURN<br />
END<br />
The main c file is below.
<br />
<br />
#include <stdio.h><br />
#include <string.h><br />
<br />
<br />
<br />
extern "C" void _stdcall DLL_ROUT (<br />
int *INT_ARG,<br />
char *STR_IN,<br />
int STR_IN_LEN,<br />
char *STR_OUT,<br />
int STR_OUT_LEN);<br />
<br />
void main (int argc, char *argv[])<br />
{<br />
char instring[40];<br />
char outstring[40];<br />
int intarg;<br />
<br />
strcpy(instring,"Testing...");<br />
intarg = 123;<br />
<br />
DLL_ROUT(&intarg,instring,strlen(instring),outstring,40);<br />
printf("%s\n",outstring);<br />
}<br />
Thanks Ken
|
|
|
|
|
Are you using MSVC++ 5.0? There's a compatibility problem that prevents 5.0 from using import libraries built for 6.0. The latest SP for MSVC++ 5.0 seems to fix this.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes Joaquin. I am using MS VC 5.0.
The library was built using Compaq Visual Fortran 6.0
Not sure what is the SP? Are there any work arounds?
Thanks
|
|
|
|
|
Hello,
After deleting a control in a DialogBar, using in VC++ 6.0's Dialog Editor, my program crashes upon the following code execution in the DialogBar's class:
CGoalsDoc* pDoc = (CGoalsDoc*)((CMainFrame *)<br />
AfxGetApp()->m_pMainWnd)->GetActiveFrame()->GetActiveDocument();
The debugger says it's an "unhandled exception". It's as though my DialogBar is looking for a document that's doesn't yet exist yet? How would I go about debugging this issue?
Clues:
When commenting out the creation of my DialogBar in the CMainFrame class, the program gets further in the execution but crashes when trying to access the CMainFrame->m_DialogBar member.
My change that caused this new behavior was the deletion of a CMonthCalendar Control from my DialogBar (and maybe the associated symbol).
Any help would be appreciated! Thanks!
JennyP
|
|
|
|
|
More clue(s):
CWnd *test = AfxGetApp()->m_pMainWnd;
gives a null (0) value to test when this statement is inserted just before the statement in my previous message. Therefore, m_pMainWnd has not yet been assigned by MFC..... I'm not sure why this would suddenly stop working.
Thanks for reading this so far.
JennyP
|
|
|
|
|
can't understand clearly though what the real problem is..I can only help you in debugging. Put a breakpoint before the line you think it is creating exception and then pressing f10 f11 and shift f11 you can debug. I mean go back and forth in code to see where the actual problem occurs. Hope you find it soon..
cheers
Himanshu
|
|
|
|
|
I has this same problem just a few days ago in my derived OnFileNew handler of the CWinApp derived main program. I do some main frame control setup in the OnNewDocument() function but it would crash on startup. This solved the problem:
void CMainApp::OnFileNew()
{
if((CMainFrame *)AfxGetMainWnd())
((CMainFrame *)AfxGetMainWnd())->OnFileNew();
CWinApp::OnFileNew();
}
You should be able to do the same thing in whatever derived function is eventually getting to the affected area.
In some cases, the area that crashes has nothing to do with the actual code defect - it is just a side effect of uninitialized pointers (including class pointers) or stack corruption.
Steve
|
|
|
|
|
Hi All,
I have an owner drawn combo box, where I am trying to sort the values entered in the box, and provide some custom drawing. So, I have set the style to owner draw fixed, overridden DrawItem, and CompareItem, both of which seem to be working OK. I turned off the HAS_STRINGS style, as I am just using a struct to hold all te info in for each item.
Now, I can do custom sorting and drawing with the combo box, but the text in the edit control has disappeared! Any ideas?
Thanks,
Aaron
|
|
|
|
|
override WM_DRAWITEM (?) message, u can draw any text there, otherwise no text appears.
includeh10
|
|
|
|
|
I'm having a major brain freeze at the moment, which sucks cause I feel like an idiot, but...
Can anyone give me a short concise example of how to add/edit/delete a record froma database using CRecordsets?
I have it open and I can append to it, just not sure where to put the data that I am adding or updating.
Or point me to a nice resource online. I had this all once but lost my examples in a comptuer crash. And I'm not sure where I got my previous method for doing this.
Thanks for anyhelp on this.
The wisest of the wise may err. - Aeschylus
|
|
|
|
|
hope these links will help..
http://www.codeguru.com/mfc_database/querydef.shtml
http://www.codeproject.com/useritems/ADOClasses.asp
http://www.codeguru.com/mfc_database/
http://freespace.virgin.net/paul.maker/examples.htm
cheers..
Himanshu
|
|
|
|
|
Those links helped me to realize I can do what I need via SQL and the database connection. Not exactly how I wanted to do it, but since I can't quite get down the method using the AddNew() and the other, I will use SQL until I can find a precise example of what I need. thank you much for the links though.
The wisest of the wise may err. - Aeschylus
|
|
|
|
|
Hi,
A have a CPropertySheet with more pages. It's a wizard. I don't use the default buttons (next, back, finish). Each page has it's buttons. I have a "Cancel" button and I'm trying to end the sheet when this button it is pressed but I don't seem to realize that.
The closest thing was this:
CPropertySheet* sheet = (CPropertySheet*) GetParent();
CPropertyPage::OnWizardFinish();
sheet->EndDialog(1);
which destroyed the page but the dialog frame remained.
Do you have some suggestions? Thanks.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Try calling OnOK on your sheet pointer, or posting a WM_CLOSE message.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I've tried with OnOK(), OnCancel and still nothing happens.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
What about posting WM_CLOSE ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I will try now. But I think I just realised why I have this problem. I have a dialog and in the OnInitDialog method I create a CPropertySheet. And I was trying to cancel the main dialog and not the propertysheet.
Thanks for the help!
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Hi everyone,
I want to add text to a editcontrol from a file but the text is inserted in one line.How can i add lines in the editcontrol so the text has the same format as in the text file;
|
|
|
|
|
Try replacing "\n" s with "\r\n" s.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
first of all, I do this in pure API, but it's all wrapped up in MFC so you shouldn't really have any problems
I need to upload some memory data to ftp. I open the internet and connect (InternetOpen, InternetConnect), I open a ftp file using FtpOpenFile... so far I guess it's all right, no errors, FTP server's log looks quite okay. (btw. I do with GENERIC_WRITE).
Then I try to upload data using InternetWriteFile(handle_from_ftpopenfile, buffer, length_of_the_buffer, &written);
the problem is that when I walk thru the code or call sleep to suspend the thread before calling the InternetCloseHandle for a while (which is weird. It shouldn't do anything then unless it uploads in a separate thread, but what that written parameter is for then?) the file uploads okay. If I just run it, the file is created but is empty (0 bytes).
In both cases the InternetWriteFile returns false, GetLastError is 0, InternetGetLastResponseInfo is 0 (and error buffer is "").
I guess the cause might be the InternetCloseHandle (I've read somewhere that it cancels the operations pending. But the InternetWriteFile should be synchronous, or not?). So what's up and how can I determine when it's safe to call InternetCloseHandle...
|
|
|
|
|
I am using CDatabase and I want to be able to open the database without the user having to select anything. (Users like to break stuff, I want no breaking) I can get it so I just have to select the database with this code:
dbSNDB.OpenEx("DSN=MS Access Database,", 0);
And I am wondering if there is anything I can do to make it so it open's the database automtically. I am still having to select the database from the options it pops up.
Thanks
The wisest of the wise may err. - Aeschylus
|
|
|
|
|
If there's only one database you can do this:
bd.Open(_T("Your-DSN"),FALSE, FALSE, _T("ODBC;UID=yourUserName;PWD=yourPass;Database=yourDb"));
if (bd.IsOpen())
// it's ok
else {
// error
}
If you want the user to select a database you can let him choose from a list (but not the one opened by ODBC). Then you try to open the connection with the database selected by the user with the code above. If there's any error you display an error message.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
I've tried this both with VC6 on one machine, and imported the project to VC7 on another. It worked on neither. Try the code below. After running OnWriteOut(), right click on the file in the shell, click on "Properties", and go to the "Summary" tab. Viola! Here, I'm getting only some "default" properties, and the application name ("The Application v 1.0") doesn't show up anywhere! However, if you copy the SAME FILE over to a Win2k machine, it shows up fine. You'll notice that if you set a breakpoint in OnReadIn() after the ReadMultiple call however, all the properties (including app name) come in just fine programmtically. Am I doing something wrong here? If this is confirmed, how do I report this to MS?
P.S. This is in SP1, and I'm looking at the "Advanced" view of the Summary
---------
Code
---------
void CTestwritepropsDlg::OnWriteOut()
{
HRESULT hr = S_OK;
IStorage* pStg = NULL;
hr = ::StgCreateStorageEx(CComBSTR("C:\\out.test"),
STGM_CREATE | STGM_READWRITE | STGM_TRANSACTED,
STGFMT_DOCFILE, 0,
NULL, NULL, IID_IStorage, (void**)&pStg);
ASSERT(SUCCEEDED(hr));
IPropertySetStorage* pPropSet = NULL;
hr = pStg->QueryInterface(IID_IPropertySetStorage, (void**)&pPropSet);
ASSERT(SUCCEEDED(hr));
IPropertyStorage* pProps = NULL;
hr = pPropSet->Create(FMTID_SummaryInformation, NULL, 0,
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
&pProps);
ASSERT(SUCCEEDED(hr));
PROPSPEC specs[] = {{PRSPEC_PROPID, PIDSI_APPNAME},
{PRSPEC_PROPID, PIDSI_COMMENTS},
{PRSPEC_PROPID, PIDSI_TITLE},
{PRSPEC_PROPID, PIDSI_AUTHOR} };
PROPVARIANT vars[4];
PROPVARIANT var;
PropVariantInit(&var);
var.vt = VT_LPSTR;
var.pszVal = "The Application v 1.0";
vars[0] = var;
var.pszVal = "Some comments";
vars[1] = var;
var.pszVal = "The Title of the Document";
vars[2] = var;
var.pszVal = "Bill Gates";
vars[3] = var;
hr = pProps->WriteMultiple(4, specs, vars, 0);
ASSERT(SUCCEEDED(hr));
hr = pProps->Commit(STGC_DEFAULT);
ASSERT(SUCCEEDED(hr));
pProps->Release();
pPropSet->Release();
hr = pStg->Commit(STGC_DEFAULT);
ASSERT(SUCCEEDED(hr));
pStg->Release();
}
void CTestwritepropsDlg::OnReadIn()
{
HRESULT hr = S_OK;
IStorage* pStg = NULL;
hr = ::StgOpenStorageEx(CComBSTR("C:\\out.test"),
STGM_READWRITE | STGM_TRANSACTED,
STGFMT_DOCFILE, 0,
NULL, NULL, IID_IStorage, (void**)&pStg);
ASSERT(SUCCEEDED(hr));
IPropertySetStorage* pPropSet = NULL;
hr = pStg->QueryInterface(IID_IPropertySetStorage, (void**)&pPropSet);
ASSERT(SUCCEEDED(hr));
IPropertyStorage* pProps = NULL;
hr = pPropSet->Open(FMTID_SummaryInformation,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
&pProps);
ASSERT(SUCCEEDED(hr));
PROPSPEC specs[] = {{PRSPEC_PROPID, PIDSI_APPNAME},
{PRSPEC_PROPID, PIDSI_COMMENTS},
{PRSPEC_PROPID, PIDSI_TITLE},
{PRSPEC_PROPID, PIDSI_AUTHOR} };
PROPVARIANT vars[4];
hr = pProps->ReadMultiple(4, specs, vars);
ASSERT(SUCCEEDED(hr));
pProps->Release();
pPropSet->Release();
hr = pStg->Commit(STGC_DEFAULT);
ASSERT(SUCCEEDED(hr));
pStg->Release();
}
|
|
|
|
|
hi. i am working on a MFC SDI project. i use below code for changing the cursor.
HCURSOR cur;<br />
cur=AfxGetApp()->LoadStandardCursor(IDC_IBEAM);<br />
SetCursor(cur);
but it don't work. my cursor is not Static. for example i write this code in OnLButtenDown function. even i change the cursor with a left-Click then a moment later it changes to default cursor (IDC_ARROW).
if i write the code in OnMouseMove and then i move the mouse over the main window the Cursor will flicker and will change to my cursor and then will change to Defualt cursor and even i stop moving the mouse it will became default mouse cursor
what can i do to Creat a Static Cursor in a SDI ?
|
|
|
|
|
You need to handle the WM_SETCURSOR message. Windows sends this to your window everytime the mouse is moved - that is why your cursor changes back almost straight away.
Dave
|
|
|
|
|