|
|
But why buy expensive books when u learn learn learn from the internet!
It's how i got all my knowledge (not that its that much lol) and the books i did buy (3 now, and only 1 is about C/C++) didn't help me much at all!
Oh wait.. there's a simple answer to my first question. Don't say it! To pay the authors salary because we might end up writing a book of our own one day and we would want people to buy it and not just look it all up on the internet.
Kuniva
--------------------------------------------
|
|
|
|
|
I highly recommend Network Programming for Microsoft Windows, Second Edition
by Anthony Jones and Jim Ohmund.
Kuphryn
|
|
|
|
|
Hi,
How can I access to I/O port in NT Windows?
Thank you for your guides, beforehand.
|
|
|
|
|
You can use WinRT http://www.pds-site.com/Bsquare/WinRT/default.htm[^].
Or you could write your own device driver.
However, user mode code isn't allowed to access i/o ports directly since that would be a security violation.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
i am so utterly frustrated right now.. i have been trying to pass a string from VB into a function, modify it and return it back to VB.. but i just cannot understand this BSTR crap.. i have tried to accomplish this 2 ways and im stuck both.. so im gunna list em both, and maybe someone will know how to fix one? thanks a bunch for any advice..
Problem number 1:
I pass 3 variables into my function..
FindBankName(strFilename, strRoutingNumber, strBankName)
when i call this function from VB i pass it these values in this order:
("C:\\FedACHdir.txt", "282976020", "bankname")
but as you will see below my c++ function does not get them in this order..
c++ function:
void __stdcall CFpsPayTaxxApp::FindBankName(BSTR strFilename, BSTR strRoutingNumber, BSTR strBankName)
{
CString strTemp;
strTemp = "The Filename passed is: >" + (CString) (LPCTSTR)strFilename + "<";
AfxMessageBox(strTemp);
strTemp = "The RoutingNumber passed is: >" + (CString)(LPCTSTR)strRoutingNumber + "<";
AfxMessageBox(strTemp);
strTemp = "The BankName passed is: >" + (CString)(LPCTSTR)strBankName + "<";
AfxMessageBox(strTemp);
}
what i get for output is 3 message boxes.. the first says ">282976020<", the second ">bankname<", and the third has funky characters.. so the first parameter is never seen.. i have tried passing by reference, not by reference, passing with a return value, without a return value, passing as char* instead of BSTR, but i never get the first parameter.. the other problem with this approach is that i crash when i modify the passed in BSTR's..
Problem number 2:
I tried to take an ATL dll that is on CP which has examples involving BSTR's.. i got that dll to work fine with the parameters being passed.. the function even modified the string and returned it as modified (which i cant seem to do in the first method at all without crashing).. the problem here is that i can't seem to modify the string and return it.. probably because i am not handling the BSTR's properly.. but at least the example works, its just way to cryptic for me.. here is what i have trying to just return the variable modified.. it doesn't work either..
void __stdcall GetBankName(BSTR strFilename, BSTR strRoutingNumber, BSTR strBankName, BSTR strErrResponce)
{
strBankName = "what the?";
} this doesnt change the text.. and the example i have i cant even follow..http://www.codeproject.com/dll/superdll.asp[^]
Conclusion:
problem #1 working would be alot better for me because i could use CStrings and other MFC things, where as problem #2 uses ATL and I am so lost dealing with these BSTR strings.. all I need to do is be able to set a char* array to a BSTR.. but i just cant seem to follow it..
if you have any idea what im doing wrong in #1, or can offer some suggestions on understanding modifying BSTR's in problem #2 i would be very appreciative.. thanks
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
"(CString) (LPCTSTR)strFilename " is very bad idea.
try
a)
#include "comdef.h"
CString str = _bstr_t(strFilename);
b.)
CString str = OLE2T(strFilename);
|
|
|
|
|
ill keep that in mind.. how would i turn it back to a CString, or better yet how would i turn a BSTR to a char* and then back to a BSTR?
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
void functionF(BSTR bstr)
{
CComBSTR cBstr = bstr;
CString str(bstr);
CString strAppend;
strAppent = str + CString(bstr); //Appending Strings
strAppend += str;
//Similiar with CComBSTR and _bstr_t
}
|
|
|
|
|
hrm.. seems the whole problem is that i was listing the classname in front of the function like:
void __stdcall CFpsPayTaxxApp::FindBankName(BSTR strFilename, BSTR strRoutingNumber, BSTR strBankName)
i took off the classname in front of the function and it now the vars come in fine..
void __stdcall FindBankName(LPSTR strFilename, LPSTR strRoutingNumber, LPSTR strBankName)
wierd stuff.
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Hello,
I have never tried to load a dialog box from a dll.. I have created a Static MFC DLL and created a dialog within the dll.. I used this to export the class hoping that this would allow me to use the dialog..
class AFX_EXT_CLASS CSettingsDlg : public CDialog
{
public:
CSettingsDlg();
~CSettingsDlg();
enum { IDD = IDD_SETTINGS }; <------HERE
..... BLAH BLAH
The problem is when I add the .lib, .h and dll to the other application and try to compile it I get an error on this line..
enum { IDD = IDD_SETTINGS }; <--
Any ideas?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
You need to set the resource handle to the dll the switch it back again;
you should see a line of code like this somewhere in your dll, probably near DllMain function:
static AFX_EXTENSION_MODULE MyDLL = { NULL, NULL };
define a
HMODULE MyModuleHandle;
globally;
in DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
...
new CDynLinkLibrary(MyDLL);
//Add this line
MyModuleHandle = MyDLL.hModule;
}
then before you create your dialog, do something like this:
HINSTANCE pPreviousInstance = AfxGetResourceHandle();
AfxSetResourceHandle(MyModuleHandle);
m_pMyDialog = new CMyDialog();
...
AfxSetResourceHandle(pPreviousInstance);
this should solve that problem..
"Life begins at 140"
|
|
|
|
|
Try adding:
#include "resource.h"
to the top of the header file (SettingsDlg.h).
Regards,
Alvaro
Quitters never win. Winners never quit. But those who never win and never quit are idiots. -- despair.com
|
|
|
|
|
Hello!
How can i change a menu name on runtime. With the menu-name i mean by example "File", "Edit" or "Help". Submenu's is not a problem for me because they have a ResourceID, but the menu's that i want to change on runtime does not have that, or i can't find them?
Thanks for helping me.
|
|
|
|
|
I haven't tried this but it should work.. where 0 is the first item on the menu like "File".
CMenu *pMenu = GetMenu();
CString csMnuStr;
pMenu->GetMenuString(0, csMnuStr, MF_BYPOSITION);
pMenu->ModifyMenu(0, MF_BYPOSITION, 0, "New Text");
DrawMenuBar();
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Thanks!
Now automaticly all the menu-item texts goes through a translate function. So that my program works with different language's.
<br />
CMenu *pMenu = GetMenu();<br />
CMenu *pSubMenu;<br />
CMenu *pSubSubMenu;<br />
<br />
CString csMnuStr;<br />
<br />
for(int i=0; pMenu->GetMenuState(i, MF_BYPOSITION) != -1; i++)
{<br />
if(pMenu->GetMenuString(i, csMnuStr, MF_BYPOSITION) < 1)
continue;<br />
<br />
pMenu->ModifyMenu(i, MF_BYPOSITION, 0, theApp.translate(csMnuStr));<br />
<br />
pSubMenu = pMenu->GetSubMenu(i);
<br />
if(pSubMenu == NULL)
continue;<br />
<br />
for(int j=0; pSubMenu->GetMenuState(j, MF_BYPOSITION) != -1; j++)
{<br />
if(pSubMenu->GetMenuString(j, csMnuStr, MF_BYPOSITION) < 1)
continue;<br />
<br />
pSubMenu->ModifyMenu(j, MF_BYPOSITION, 0, theApp.translate(csMnuStr));<br />
<br />
pSubSubMenu = pSubMenu->GetSubMenu(j);
<br />
if(pSubSubMenu == NULL)
continue;<br />
<br />
for(int k=0; pSubSubMenu->GetMenuState(k, MF_BYPOSITION) != -1; k++)
{<br />
if(pSubSubMenu->GetMenuString(k, csMnuStr, MF_BYPOSITION) < 1)
continue;<br />
<br />
pSubSubMenu->ModifyMenu(k, MF_BYPOSITION, 0, theApp.translate(csMnuStr));<br />
} <br />
}<br />
}<br />
DrawMenuBar();<br />
|
|
|
|
|
Thanks!
Now automaticly all the menu-item texts goes through a translate function. So that my program works with different language's.
<br />
CMenu *pMenu = GetMenu();<br />
CMenu *pSubMenu;<br />
CMenu *pSubSubMenu;<br />
<br />
CString csMnuStr;<br />
<br />
for(int i=0; pMenu->GetMenuState(i, MF_BYPOSITION) != -1; i++)
{<br />
if(pMenu->GetMenuString(i, csMnuStr, MF_BYPOSITION) < 1)
continue;<br />
<br />
pMenu->ModifyMenu(i, MF_BYPOSITION, 0, theApp.translate(csMnuStr));<br />
<br />
pSubMenu = pMenu->GetSubMenu(i);
<br />
if(pSubMenu == NULL)
continue;<br />
<br />
for(int j=0; pSubMenu->GetMenuState(j, MF_BYPOSITION) != -1; j++)
{<br />
if(pSubMenu->GetMenuString(j, csMnuStr, MF_BYPOSITION) < 1)
continue;<br />
<br />
pSubMenu->ModifyMenu(j, MF_BYPOSITION, 0, theApp.translate(csMnuStr));<br />
<br />
pSubSubMenu = pSubMenu->GetSubMenu(j);
<br />
if(pSubSubMenu == NULL)
continue;<br />
<br />
for(int k=0; pSubSubMenu->GetMenuState(k, MF_BYPOSITION) != -1; k++)
{<br />
if(pSubSubMenu->GetMenuString(k, csMnuStr, MF_BYPOSITION) < 1)
continue;<br />
<br />
pSubSubMenu->ModifyMenu(k, MF_BYPOSITION, 0, theApp.translate(csMnuStr));<br />
} <br />
}<br />
}<br />
DrawMenuBar();<br />
|
|
|
|
|
Thanks!
Now automaticly all the menu-item texts goes through a translate function. So that my program works with different language's.
<br />
CMenu *pMenu = GetMenu();<br />
CMenu *pSubMenu;<br />
CMenu *pSubSubMenu;<br />
<br />
CString csMnuStr;<br />
<br />
for(int i=0; pMenu->GetMenuState(i, MF_BYPOSITION) != -1; i++)
{<br />
if(pMenu->GetMenuString(i, csMnuStr, MF_BYPOSITION) < 1)
continue;<br />
<br />
pMenu->ModifyMenu(i, MF_BYPOSITION, 0, theApp.translate(csMnuStr));<br />
<br />
pSubMenu = pMenu->GetSubMenu(i);
<br />
if(pSubMenu == NULL)
continue;<br />
<br />
for(int j=0; pSubMenu->GetMenuState(j, MF_BYPOSITION) != -1; j++)
{<br />
if(pSubMenu->GetMenuString(j, csMnuStr, MF_BYPOSITION) < 1)
continue;<br />
<br />
pSubMenu->ModifyMenu(j, MF_BYPOSITION, 0, theApp.translate(csMnuStr));<br />
<br />
pSubSubMenu = pSubMenu->GetSubMenu(j);
<br />
if(pSubSubMenu == NULL)
continue;<br />
<br />
for(int k=0; pSubSubMenu->GetMenuState(k, MF_BYPOSITION) != -1; k++)
{<br />
if(pSubSubMenu->GetMenuString(k, csMnuStr, MF_BYPOSITION) < 1)
continue;<br />
<br />
pSubSubMenu->ModifyMenu(k, MF_BYPOSITION, 0, theApp.translate(csMnuStr));<br />
} <br />
}<br />
}<br />
DrawMenuBar();<br />
Willem
|
|
|
|
|
try DrawMenuBar()
CodeTheDreams();
|
|
|
|
|
Within a few days I'll begin to submit my arguments.
|
|
|
|
|
Mr. Andrea wrote:
Within a few days I'll begin to submit my arguments.
On what subject ?
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Why?
Quitters never win. Winners never quit. But those who never win and never quit are idiots. -- despair.com
|
|
|
|
|
Hi,
i like to save received data files (.pmj) from a scanner serially numbered on my disc (001.pmj, 002.pmj, ...) I know i must work with a loop and a variable, but it is too tricky for me.
Untill now i do the following:
// Save the file...
if (r)
{
CString fileName = "e:\\data\\001.pmj";
SavePMJStream(fileName);
}
Thanks for help, Mark
|
|
|
|
|
use a int variable to hold the counter ( file number )
use CString::Format to format the counter into a string.
use the for loop to increment the counter and format filename as a string, and pass it to the SavePMJStream .
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
macmac38 wrote:
Untill now i do the following:
// Save the file...
if (r)
{
CString fileName = "e:\\data\\001.pmj";
SavePMJStream(fileName);
}
----------------------------
CString csPath, csFileName;
int nLastFile;//Keep SomeWhere (Registry/file)
csPath = "e:\\Data\\";
if (r)
{
csFileName.Format("%03d", ++nLastFile);
csPath +=csFileName;
SavePMJStream(csPath);
}
Why Not THIS.?????
CodeTheDreams();
|
|
|
|
|