|
It's a typo.
IAREM32 pcAny; Should be...
IAWREM32 pcAny; Good luck!
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
<nobr>
Homepage : Feature Article : Sonork = 100.16311
|
|
|
|
|
Hi Jeremy,
Got it to go. One more question, if I may. I have inserted code to display a statement with a printf at the construcion function, as is indicated by the base code. I pop the window, but don't see the printf output. I have written alot of "C" code from scratch, but in a DOS environment, so I am not used to the base codes as is created in the windows environment. Am I placing my code in the wrong place or am I missing something else. Your help is always appreciated.
// testa.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "testa.h"
#include "awrem32.h"
#include "io.h"
#include "conio.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IAWREM32 pcAny;
/////////////////////////////////////////////////////////////////////////////
// CTestaApp
BEGIN_MESSAGE_MAP(CTestaApp, CWinApp)
//{{AFX_MSG_MAP(CTestaApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestaApp construction
CTestaApp::CTestaApp() // <---- THIS IS WHERE I THOUGHT THE CODE SHOULD GO
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
CString rc;
rc = pcAny.GetError();
printf( "Return Code = %s/n", rc );
getch();
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CTestaApp object
CTestaApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CTestaApp initialization
BOOL CTestaApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
// To create the main window, this code creates a new frame window
// object and then sets it as the application's main window object.
CMainFrame* pFrame = new CMainFrame;
m_pMainWnd = pFrame;
// create and load the frame with its resources
pFrame->LoadFrame(IDR_MAINFRAME,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
NULL);
// The one and only window has been initialized, so show and update it.
pFrame->ShowWindow(SW_SHOW);
pFrame->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CTestaApp message handlers
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CTestaApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CTestaApp message handlers
|
|
|
|
|
You'll want to use something else. I sent you an email with a couple of functions, but here's a sample to get you going...
void CChildView::OnPaint()
{
CPaintDC dc(this);
CRect rect;
CString data = "Howdy!";
CWnd *wnd = dc.GetWindow();
::GetClientRect(wnd->m_hWnd, &rect);
dc.DrawText(data, data.GetLength(), &rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
} Use ChildView.cpp instead. You'll have to #include awrem32.h in this file also and don't forget a declare a variable (object) that's in scope.
BTW, I used my own string because GetError() didn't return anything. I assume that's because there were no errors.
Also, if you haven't gotten a book yet on Windows programming then you may want to do it pronto. I can tell you from experience, this is not optional.
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
<nobr>
Homepage : Feature Article : Sonork = 100.16311
|
|
|
|
|
Hi Jeremy,
all the books I have are "C" without windows. Do you have a recommendation for a good book with lots of samples. I can usually take a sample and modify it the way I need it. I'm pretty good at that. I am trying the new sample code as we speak. thanks again for your help.
|
|
|
|
|
Hi Jeremy,
Tried the code you sent. Got it working EXCEPT, can't seem to get a CR\LF to work so the messages go down the page. Any ideas?
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
CRect rect;
char* data = " Dialing xxxxxx\r\n";
CWnd *wnd = dc.GetWindow();
::GetClientRect(wnd->m_hWnd, &rect);
dc.DrawText(data, strlen(data), &rect, DT_WORDBREAK);
dc.SetTextAlign(TA_RIGHT);
// Dialing the Host
pcAny.awConnect("xxxxxx");
rc = pcAny.GetError();
data = " \r\nConnection = ";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
dc.DrawText(rc, rc.GetLength(), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
// Getting Status of Connection
rc2 = pcAny.ConnectionStatus();
data = " \r\nConnection Status = ";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
itoa(rc2, data, 10);
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
// Sending the Order(s)
data = " \r\nSending Orders\r\n";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
pcAny.FileXferToHost("TESTFILE.TXT","TESTFILE.TXT");
rc = pcAny.GetError();
data = " \r\nSending = ";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
dc.DrawText(rc, rc.GetLength(), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
// Getting the New Catalog
data = " \r\nUpdating Catalog\r\n";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
pcAny.FileXferFromHost("CATALOG.TXT","CATALOG.TXT");
rc = pcAny.GetError();
data = " \r\nUpdating = ";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
dc.DrawText(rc, rc.GetLength(), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
// Host Disconnect
data = " \r\nDisconnecting from Host\r\n";
dc.DrawText(data, strlen(data), &rect, DT_RIGHT|DT_WORDBREAK);
dc.SetTextAlign(TA_UPDATECP);
pcAny.awDisconnect();
delete pcAny;
}
|
|
|
|
|
Hi Jeremy,
The code acually compiled. Thanks a bunch. I will now attept to put in the rest of the functions and see if the thing will work.
Thanks again.
I owe you one.
|
|
|
|
|
Well, this damn thing is really trying my limited patience..
1) It won't save changes to the projects. It asks me if I want to save changes, but after doing so, the changes aren't there.
2) The .sln file ("solution", what a wonderfully cute term) it creates won't open; probably related to the above.
3) I get internal compiler errors when compiling anything that contains ATL (and I'm not even sure why this happens, since we don't use ATL):
C:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\include\atlsimpstr.h(583): fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 2844)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Are there known solutions for this nonsense?
TIA
|
|
|
|
|
Jim A. Johnson wrote:
Are there known solutions for this nonsense?
(i just want to be the first to say it)
VC6
other than that, good luck
-c
Conscience is what hurts when everything else feels good.
Smaller Animals Software, Inc.
|
|
|
|
|
VC7 works like a champ.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
|
Yup, not exactly a shocker. :/
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
The resource studio also gone from Excellent (VC6.0) to a bag of shite (VC7.0)
Along with other minor quirks it looks like they compromised VC++ for other other noddy languages that the studio supports.
phew... glad i got that of my chest
Normski. - Professional Windows Programmer
|
|
|
|
|
I salute you all,
I am trying to make a tool box like Paint's Toolbox. But When i used Spy++, I saw that there are 2 objects; first one is CControlBar object and CWnd object which buttons are placed.
My question is how can we make a toolbox based on CWnd class like Paint.
Thanks.
|
|
|
|
|
I have some troubles with making Add-In for VS.NET.
I need to receive Event about saving document and Build complete.
Can you have me with any information ? MSDN page, source or any other...
( Add-in in C++ )
Thank you.
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
I need to debug a CGI app made with VC++. The only way it can be executed is like http://localhost/cgi-bin/prog.exe?var1=20&var2... etc.
this may be a newbie question, but how can I set a breakpoint in VStudio that will be triggered when I execute the CGI app? I thought about adding an ASSERT(FALSE); in the code so I could enter in the code but I guess there's a better way to do it.
I have a bug that is probably nothing but not being able to see what's really happening makes it difficult to fix it.
thanks guys!
---------------
Your image solutionist on the World Wide Web
http://www.edovia.com
|
|
|
|
|
Use the console. The console uses STDIN and STDOUT just as the CGI does. Instead of passing your params via GET, just use the command line params for development and switch them over to HTTP vars afterwards.
Or, if I just need to a debug something simple and quick, I'll hardcode a value and run with that.
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
<nobr>
Homepage : Feature Article : Sonork = 100.16311
|
|
|
|
|
I just debug the CGI directly from Visual Studio as a standalone application (hitting F5), passing the parameters as command line args (there's an editbox in the Project settings for this purpose), and having the app begin with the following lines:
int main(int argc, char **argv)
{
#ifdef _DEBUG
if(argc>=2){
std::string str("QUERY_STRING=");
str+=argv[1];
_putenv(str.c_str());
}
#endif
...
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
In my VC++ MTS program I am trying to send and receive an XML document using MSMQ. The send part works fine, but I am having problems with the receive part. I am using ActiveX smart pointers for the MSMQ queues and message. Everything works fine until I try to reference the Body of the message (pMsg->Body) and the I get an -2147221164 Class not Registered error. I get this even with the get_Body call. Can anyone help me?
|
|
|
|
|
I want after my application run ,the executable file DELETE itself.Is that possible?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Mazdak wrote:
Is that possible?
No
-----------------------
Perhaps if you make a batch file and run that batch file when closing your app.
Make loop in your batch file that tries to delete your EXE!
but your batch file will still be there...
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
So,how can I make it run only for ONE time? Like trial version programs.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Hi Mazy
How can you make it delete itself, it will be in use at the time and therefore cause an access denied prompt???
Me
|
|
|
|
|
alternatively i have just thought, Make a second app and get that to delete the first, waiting for the first one to delete. Therefore you will be left with the second app. Which is just there to remove the first and contains no info. alternatively again make a batch file
|
|
|
|
|
Sorry, but then I can't help you!
But if you want an unsafe way to do it: Write something to a file (EXE, DLL or just a file) in binary (of course) and then read from that file to see if it has run before!
Understand?
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
There a solution to that in msdn, if u don't find email me at blackhorus@caramail.com, so i can send u the article.
|
|
|
|
|