|
Hello all.
I am building a program presently for a couple of people to work with. The program changes quite often (many times during the week) because it is in its Alpha stages. What I am wanting to do is incorporate a "help/about" button on some of the dialogs that will open up another window/dialog with some information in it.
Currently, I am using a listbox with no selection enabled. In my OnInitDialog() I have it populate this listbox using AddString(). This listbox I have setup to be "non selectable" so that you can just read and scroll.
I am wondering, is this the best way to do it, or is there some other control that I can use to put text into and allow the user to scroll up and down (without being able to select individual lines).
Also, if listbox w/ none selection enabled is the best way, I am wondering if there is a way I can make this process easier on myself. Currently, I have to have lots and lots of AddString()'s in there to put the help. When I make changes so often to the program, I have to spend a lot of time going through the AddString() statements to reflect the changes that I've made. What I'm really looking for is a way that I can have a text file that gets compiled into the APP during a compile. This way, I can have a text file that I can open up in textpad and make modifications to after I make code changes, and then, once I recompile, voila, all that information in that text file gets compiled into the .EXE. (I want to get away from having to distribute the APP with the .TXT file and having to reinstall the text file every time I re-release the new alpha version. I don't want a "disk read" in order to populate this "list box".
Any ideas on the best method of incorporating this would be greatly appreciated.
Shultas
|
|
|
|
|
|
I'm programming with VC++7 in MFC. I must know the path where my app is. I know that I should use the object "theApp", but I can't find anything that gave my app its location.
Thx.
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
|
Can you show me an example please?? I can't make it work.
I am using hModule as NULL because I want to now my executable file path.
Thx.
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
How does your code look like?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
static const int BUFSIZE = 1024;
DWORD cchBuff = BUFSIZE;
TCHAR tchBuffer[BUFSIZE] = {0};
LPTSTR lpszPath = tchBuffer;
DWORD dwResult;
dwResult = ::GetModuleFileName(NULL, lpszPath, cchBuff);
std::cout << "Path to EXE is: " << lpszPath;
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Rafael Fernández López wrote:
I can't make it work.
Meaning what, you get compiler/linker errors, a run-time error, or the value of lpFilename is wrong after the function call? How about a code snippet of what does not work?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I compile my projects using this platform. When i give exe-files, compiled by it, to my friend application doesn't find all dll it needs, because friens don't have this platform. But when i had seen what dll it wants, i realized that it wants dll related to netframework, which i don't use in my applications. And i don't know how to exclude it from using.
|
|
|
|
|
Are you sure you're not using any managed extensions? Try using SPY++ to see which modules your app calls.
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
I ran across a document a while back about this issue. (This is why I have not used my .NET that I paid over $1K for!). The article stated that any program that you compile with Visual Studio .NET requires the .NET Framework to be installed on the client machine running that program.
The article stated that future versions of Windows will be shipped with the framework, but as of now you have to download and install it from the Microsoft web site. (This is primarily why I've not developed anything with it, because I was nervous that the people running my program would have to spend hours downloading the framework in order for a simple utility to run).
I may be entirely wrong, someone please correct me if I am (I'll be installing 5 minutes after your message!). But I did read a document that stated that.
Shultas
|
|
|
|
|
shultas wrote:
The article stated that any program that you compile with Visual Studio .NET requires the .NET Framework to be installed on the client machine running that program.
That is incorrect. You can still write C/C++ apps that are completely native.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt
|
|
|
|
|
...Installing VS .NET right now!!!! I've had the program for almost a year now without using because of this fear!!!
Thanks for your post!
PS: Sorry for the incorrectness of what I've read all!
|
|
|
|
|
Heh, it is a VERY common mistake. Microsoft hyped .NET so much that many people think that VS.NET only produces .NET programs.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
If you sure that you can write application without loading unnecessary DLLs.
Could you help me how to prevent their loading.I use Win API.
|
|
|
|
|
What is the name of the DLLs? The usual problem is that someone tries to ship the debug build which links to debug DLLs.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
It shows error message about register.That some NET. Framework Key should point on NET. Framework location.
|
|
|
|
|
Hello
Below is my code about List Iterator. It is ok when
i compile it. But when i try to build it. the following
errors come up.
"DoubleOrderedLinkedList.obj : error LNK2019: unresolved external symbol "public: int __thiscall ListIterator::getNext(void)" (?getNext@?$ListIterator@H@@QAEHXZ) referenced in function _main"
Could any body here help me solve this problem?
Thanks,
Andre
------------------------------------------------
template
class DoubleOrderedLinkedList;
template
class ListIterator;
template
class Node
{
Object data;
Node * next;
Node * prev;
Node(const Object& newItem) :
data (newItem),
next (0),
prev (0)
{}
friend DoubleOrderedLinkedList<object>;
friend ListIterator<object>;
};
template
class DoubleOrderedLinkedList
{
Node<object>* head;
int numItems;
public:
DoubleOrderedLinkedList();
~DoubleOrderedLinkedList();
int size() const;
void Insert(const Object&);
void Remove(const Object&);
void Purge();
void displayList() const;
ListIterator<object> Iterator() const;
friend ListIterator<object>;
};
template
class ListIterator
{
int pos;
Node<object>* curr;
public:
ListIterator(Node<object>* const);
bool hasNext() const;
Object getNext();
bool hasPrevious() const;
Object getPrevious();
};
#include
#include "DoubleOrderedLinkedList.h"
#include "ListIterator.h"
using namespace std;
template
DoubleOrderedLinkedList<object>::DoubleOrderedLinkedList() :
head (0),
numItems (0)
{}
template
DoubleOrderedLinkedList<object>::~DoubleOrderedLinkedList()
{}
template
DoubleOrderedLinkedList<object>::size() const
{
return numItems;
}
template
ListIterator<object> DoubleOrderedLinkedList<object>::Iterator() const
{
ListIterator<object> it (head);
return it;
}
template
void DoubleOrderedLinkedList<object>::Insert(const Object& x)
{
Node<object>* previous = 0;
Node<object>* curr = head;
while ((curr != 0) && (curr->data < x))
{
previous = curr;
curr = curr->next;
}
Node<object> * const newNode = new Node<object> (x);
if (head == 0)
{
head = newNode;
}
else
{
if (curr == head)
{
newNode->next = curr;
curr->prev = newNode;
head = newNode;
}
else
{
if (curr != 0)
{
newNode->next = curr;
newNode->prev = curr->prev;
curr->prev->next = newNode;
curr->prev = newNode;
}
else
{
newNode->prev = previous;
previous->next = newNode;
}
}
}
numItems++;
}
template
void DoubleOrderedLinkedList<object>::displayList() const
{
Node<object>* ptr = head;
cout << "[ ";
while (ptr != 0)
{
cout << ptr->data << " ";
ptr = ptr->next;
}
cout << " ]" << endl;
}
int main()
{
DoubleOrderedLinkedList l;
l.Insert(10);
l.Insert(5);
l.Insert(15);
l.displayList();
ListIterator it = l.Iterator();
cout << "Testing Iterator" << endl;
while (it.hasNext())
{
cout << it.getNext() << endl;
}
}
#include "DoubleOrderedLinkedList.h"
#include "ListIterator.h"
template
ListIterator<object>::ListIterator(Node<object>* const p) :
pos (0),
curr (p)
{}
template
bool ListIterator<object>::hasNext() const
{
return (pos < numItems);
}
template
Object ListIterator<object>::getNext()
{
if (hasNext())
{
Object item = curr->data;
if (curr->next != 0) {
curr = curr->next;
}
pos++;
return item;
}
else
{
//throw(Exception("No Such Element");
}
}
template
bool ListIterator<object>::hasPrevious() const
{
return (pos > 0);
}
template
Object ListIterator<object>::getPrevious()
{
if (hasPrevious())
{
if ((curr.prev != 0) && (pos < numItems))
{
curr = curr->prev;
}
Object item = curr->data;
pos--;
return item;
}
else
{
//throw(Exception("No Such Element");
}
}
|
|
|
|
|
that message is given when in the header file you wrote a function that in the cpp file is not used
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
You must have the implementation of your template class in the header file. Just copy all the functions from the .cpp file into the header file and it'll work.
And while you are at it, pick up a book on C++ and read very carefully in the chapter which handles templates.
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Is anyone aware if it is possible to pass a db handle between two seperate applications? And if so how is this accomplished... do you utilize the command line of the CreateProcess command. And if so, how would you pass it (not sure how you would convert it to a string etc). What i am trying to accomplish is not to have to open the same DB on new instances of programs designed to perform certain task. This is an ODBC connection as well. Any insight is appreciated
|
|
|
|
|
Johnny Quintanilla wrote:
...is possible to pass a db handle between two seperate applications?
By applications (and the mention of CreateProcess() ), do you mean EXEs? If so, information sent to the spawned application is on the command-line. I'm not sure a handle would be valid across a process boundary.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
>Is anyone aware if it is possible to pass a db handle between two seperate applications?
Behavior varies from one database to another, from driver, etc etc etc.
With Oracle sqlnet api handle may be can passed btw processes, also not supported.
SqlLib handle, sqllib api can be passed safely cross boundary and I think is supported.
ODBC drivers do NOT support such behavior, it may or may not work with next update of oracle or vendor driver.
Proper solution would be to build out of process STA com object, that performs access to database.
|
|
|
|
|
Handles are most often bound to the process in which it was acquired. ODBC handles fall into that category!
The post above this one mentions building an out-proc COM server for doing the actual database acces. This may or may not suit your needs. Is it necessary to share the actual connection between the processes? If not, then you can just pass the source DSN to the other processes. Otherwise, the COM server is your best shot.
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Dear friend,
I met a database assert error when I execute my program. My coding is
//======================= main.cpp=============================
//-------------------------------------------------------------
// optional information, such as a user ID and password.
// For example, "DSN=SQLServer_Source;UID=SA;PWD=abc123"
//
BOOL OpenDataBase(CDatabase *db)
{
CString connect;
BOOL openOK;
openOK = TRUE;
connect += "UID=Admin;";
connect += "PWD=anson;"; // Password of file is anson
connect += "DRIVER={Microsoft Access Driver (*.mdb)};";
connect += "DBQ=";
connect += "./database/pmsdb.mdb";
char teststr[255];
try
{ db->OpenEx(connect, CDatabase::noOdbcDialog);
}
catch ( CDBException* e)
{
MessageBox(NULL, "DataBase file error.", "PMS Error
Message", MB_OK);
e->GetErrorMessage(teststr, 255);
MessageBox(NULL, teststr, "PMS Error Message", MB_OK);
e->Delete();
openOK = FALSE;
//throw; // this statement will terminate program at once.
}
//MessageBox(NULL, "Leaving", "Test", MB_OK);
return openOK;
}
//-----------------------------------------------------------------------------
// Name: SearchRecord()
// Desc: Look for required record
//-----------------------------------------------------------------------------
static bool SearchRecord(HWND hWnd, CDatabase *db)
{
COperationRecordset rst(db);
BOOL found;
found = FALSE;
rst.Open(CRecordset::dynaset);
while (!rst.IsEOF())
{
if (rst.v_Login_User == g_strlogin)
if (rst.v_Login_Password == g_strpassword)
// Successful Login set a ture value
found = TRUE;
rst.MoveNext();
}
return found;
}
///////////////////////////////////
// This event has been defined when a Space key is push
// Then, this dialog is use for login process
// Mesage handler for DIALOG box.
///////////////////////////////////
LRESULT CALLBACK DIALOGA(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
CDatabase db;
BOOL done= FALSE;
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if(LOWORD(wParam) == IDOK)
{
// UNIT GetDlgItemText(HWMD hDlg,int nID,LPSTR lpstr,int nMax);
GetDlgItemText(hDlg,IDLOGIN,g_strlogin,80); // get login bar text
GetDlgItemText(hDlg,IDPASSWORD,g_strpassword,80); // get password bar text
MessageBox(hDlg,TEXT("Testing Login proccess "),
TEXT("PMS Exit") , MB_YESNO);
// Open database
OpenDataBase(&db);
done = SearchRecord(hDlg, &db);
db.Close();
if (done=TRUE)
{g_FrameDisplay=1;}// Change the frame
else if (done=FALSE)
{
MessageBox(hDlg, "Sorry, Your input value did not find.Please try again !",
TEXT("PMS Login Error") , MB_ICONERROR|MB_OK);
}
//End Dialog
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
if ( LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
// =============COperationRecordset.cpp : implementation file============
//
//#include "stdafx.h"
#include "COperationRecordset.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COperationRecordset
IMPLEMENT_DYNAMIC(COperationRecordset, CRecordset)
COperationRecordset::COperationRecordset(CDatabase* pdb)
: CRecordset(pdb)
{
//{{AFX_FIELD_INIT(COperationRecordset)
v_Login_User= _T("");
v_Login_Password= _T("");
//}}AFX_FIELD_INIT
m_nDefaultType = snapshot;
}
CString COperationRecordset::GetDefaultConnect()
{
return _T("ODBC;DSN=MS Access 97 Database");
}
// Table Name
CString COperationRecordset::GetDefaultSQL()
{
return _T("[Login]");
}
void COperationRecordset::DoFieldExchange(CFieldExchange* pFX)
{
//{{AFX_FIELD_MAP(COperationRecordset)
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Text(pFX, _T("[User]"), v_Login_User);
RFX_Text(pFX, _T("[Password]"), v_Login_Password);
//}}AFX_FIELD_MAP
}
/////////////////////////////////////////////////////////////////////////////
// COperationRecordset diagnostics
#ifdef _DEBUG
void COperationRecordset::AssertValid() const
{
CRecordset::AssertValid();
}
void COperationRecordset::Dump(CDumpContext& dc) const
{
CRecordset::Dump(dc);
}
#endif //_DEBUG
// ================COperationRecordset.h : header file===================
//
#include <afxdb.h>
#include <afx.h>
/////////////////////////////////////////////////////////////////////////////
// COperationRecordset recordset
class COperationRecordset : public CRecordset
{
public:
COperationRecordset(CDatabase* pDatabase = NULL);
DECLARE_DYNAMIC(COperationRecordset)
// Field/Param Data
//{{AFX_FIELD(COperationRecordset, CRecordset)
CString v_Login_User;
CString v_Login_Password;
//}}AFX_FIELD
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(COperationRecordset)
public:
virtual CString GetDefaultConnect(); // Default connection string
virtual CString GetDefaultSQL(); // Default SQL for Recordset
virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support
//}}AFX_VIRTUAL
// Implementation
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
};
Regards,
Anson Tong
|
|
|
|