|
I need to run my software (dialog based in VC++ format) in both GUI mode and CLI mode. If the user chooses to run the program by clicking the icon all the program's functionalities must run in GUI mode. if the user chooses to run the program in the command line, all the program's functionalities should run in in CLI mode. If it is running in the command line it should also perform i/o operations.
Please help me...
I really need help as soon as posible...
|
|
|
|
|
What's with all those emoticons?
I think you'll need to use a command line parameter to differentiate the different invocations. For example, "yoursoft.exe" invokes the GUI mode, but "yoursoft.exe -nogui" runs withouth the GUI. I'd put the common functionality in a lib. The lib can be linked to a GUI exe (say "yoursoftGUI.exe") and also to a console app (say "yoursoft.exe"). Then, in the console app you just continue as a console program or call yoursoftGUI, depending on the command line parameters.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
thanks...
there is only one problem left i cant perform console i/o.
can you help with with this.
thanks
|
|
|
|
|
There are Windows API to attach Console to your window.
Please refer AllocConsole() and FreeConsole() method. Those API will create console window for your application. Then you can also perform read/write operation using STDOUT, STDIN (GetStdHandle etc)....
Please let me know if you encounter any problems..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
thanks...
I'll let you know if i encountered some problem...
thanks again...
|
|
|
|
|
Hello,
We are trying to implement the file access using scattergather mode.
Can anyone give me an example of how to use this, open, read, write...
thank you
Uday
|
|
|
|
|
I've never used it, but the API is straight forward, just read ReadFileScatter() docs.
As you don't specify the scenario for use, here's another 2cents:
It's use, from what i see, would only be of real use in reading/writing custom database files that are page aligned.
Using ReadFile()/WriteFile() in overlapped mode is a much more usefull general method of file I/O.
(or even memory mapped files for that matter)
...cmk
Save the whales - collect the whole set
|
|
|
|
|
hello,
I wanted to know why can't we use OnInitMenuPopUp() function in dialog based application?In my dialog application when i right click on dialog name ;in the list of windows handler i don't get WM_INITMENUPOPUP handler.
Why so?
thanks
|
|
|
|
|
Hello,
In my Application I made a treeview that displays the system directory structure - like the tree on the left in windows explorer. I also have an Open button that opens a file (OpenFileDialog). So basically my user can browse for a file through the directory tree (the treeview) or through the Open button.
My problem is this - If the user chooses to use the Open button to open a file, when she/he does so, I want the treeview to reflect the location of the opened file. That is, to expand appropriately from the root and select the folder that contains the open file.
So far I have tried several approaches but none led to a solution ...
1) I looked in the .NET Framework, in TreeView class, for a function that takes a full path and is able to expand to and select the resulting directory. I could not find such a function.
2) I was successfull in parsing the full path I got from the open file dialog window into directories. However I found no functions in the .NET Framework that could help me track from the root to the last directory of the treeview.
If anybody knows how to solve this problem or has an approach to solving it, I would appreciate hearing it greatly.
TraileR ParK LifE 4Ever
|
|
|
|
|
If you looked in the .NET framework, does that make this a Managed C++ ( C++/CLI ) question, or a C# question ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
To Christian - this is a Managed C++ question, (Visual C++ .NET)
To Jose - Thanks for da tip. I changed my signature but the Quote button still refuses to work. I suspect its because it doesn't like any brackets in the message contents but I decided to not take those out because it would make the message less organized (...or maybe because im just to laizy to reorganize everything;P). In any case, if its not too big of a trouble, can u please just manually refer to the part of my message you want to reply about . Thanks!
TraileR ParK LifE 4Ever
|
|
|
|
|
Did you know that the "Quote Selected Text" button doesn't work when replying to your posts? I think it may be related to the > character in your signature. Would you mind removing or at least escaping it? Instead of > you can write > and it will still show the same way. Hopefully, that will fix the problem.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
hi all..I'm making a program using CListCtrl that has a find feature(so if I enter a string in edit box and click the find button, it search the CListCtrl attributes with the same string, and then set the selection mark into the attributes). What function that I should use?(I already try SetSelectionMark,but it doesn't work)
pls help...
thx
|
|
|
|
|
According to MSDN[^], I think SetItem is what you want.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thx..but how to make the previous item is not selected(because when I try to use the find function twice or more, the previous selected item is still highlighted/selected)
thx...
|
|
|
|
|
You need to call the same method to clear the selected state, just the flag you pass in changes. I don't see any other way of doing it on MSDN.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
what flag that I should use, because I didn't find any suitable flag? Pls help
thx..
|
|
|
|
|
firebolt77 wrote:
what flag that I should use, because I didn't find any suitable flag? Pls help
Here is What MSDN State for your problem :-
stateMask
Value specifying which bits of the state member will be retrieved or modified. For example, setting this member to LVIS_SELECTED will cause only the item's selection state to be retrieved.
This member allows you to modify one or more item states without having to retrieve all of the item states first. For example, setting this member to LVIS_SELECTED and state to zero will cause the item's selection state to be cleared, but none of the other states will be affected.
To retrieve or modify all of the states, set this member to (UINT)-1.
You can use the macro ListView_SetItemState both to set and to clear bits.
-----------End MSDN Specific data-----------------------------
I have marked statement your required with BOLD
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
thx...it's work now...but why the view of ClistCtrl didn't scroll automatically to the attributes(for example the ClistCtrl only preview 10 attributes,but the attributes that I want is in index 20. When I try to run the find function, although the selection mark is in index 20,but the view still previewing 1-10). How to handle this problem?
thx...
|
|
|
|
|
firebolt77 wrote:
although the selection mark is in index 20,but the view still previewing 1-10). How to handle this problem?
use CListCtrl::Scroll(...) or CListCtrl::SetSelectionMark(...) Function
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi guys,
I am using an Access database in my application.
The problem arises then when I try to update or edit a field corresponding to another field in the data base.
Consider the database contains 2 fields,namely m_NameE2 and m_NameB2.
Now I try searching out the m_NameE2 field for a given text,if found then I go for updating the corresponding m_NameB2 field.But it gives like such errors
"CRecordset is read-only"-when I use rs.Edit(),or "Attempt to Update or delete failed" for rs.Update();
I use the following code:
<br />
CString ss,gg;<br />
int present=0;<br />
GetDlgItemText(IDC_EDIT1,ss);<br />
gg=m_gedit.Get_Text();<br />
if(ss!="" && gg!="")<br />
{<br />
CDatabase db;<br />
db.OpenEx(_T("DSN=ForeignName"),CDatabase::noOdbcDialog);<br />
if(db.CanUpdate()==TRUE)<br />
{<br />
CNameRecords rs(&db);<br />
rs.Open(CRecordset::dynaset);<br />
rs.MoveFirst();<br />
<br />
do<br />
{<br />
if(rs.m_NameE2==ss)<br />
{<br />
present=1;<br />
AfxMessageBox("Data found and will be tried for modifying");<br />
break;<br />
}<br />
rs.MoveNext();<br />
}while(rs.IsEOF()!=TRUE);<br />
<br />
if(present==0)<br />
{<br />
AfxMessageBox("Data not found in English Name column !!");<br />
<br />
}<br />
<br />
else<br />
{<br />
<br />
rs.Edit();<br />
rs.m_NameB2=gg;<br />
<br />
rs.Update();<br />
<br />
SetDlgItemText(IDC_EDIT2,rs.m_Sex2);<br />
SetDlgItemText(IDC_EDIT3,rs.m_Origin2);<br />
AfxMessageBox("Data is saved successfully");<br />
<br />
}<br />
rs.Close();<br />
}<br />
else<br />
AfxMessageBox("Data is not saved,because data can't be appended in database file !!!!... ");<br />
db.Close();<br />
}<br />
else<br />
{<br />
AfxMessageBox("Data is not saved,because the fields are partially or not filled at all !!!!... ");<br />
}<br />
<br />
<br />
Please help...
|
|
|
|
|
This may or may not be related to your problem, but
joy007 wrote:
if(db.CanUpdate()==TRUE)
The documentation says CDatabase::CanUpdate returns "nonzero if the CDatabase object allows updates".
"Nonzero" doesn't mean neccesarily TRUE, which is 1. You should always write your tests this way to be on the safe side:
if (db.CanUpdate() != FALSE)
{
}
You could also check rs.CanUpdate
Besides, shouldn't you use a SELECT statement instead of traversing all the recordset looking for a record by yourself?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Ok, I am creating a c++ application that recieves files from a c# application.
The c++ code is what I am having problems with, the application tends to crash after transfering 300k of a 15 meg file (which takes about 20 seconds). Here is the c++ code:
<br />
void RecieveFile()<br />
{<br />
XBNetwork xbns;<br />
WSADATA WsaData;<br />
if(WSAStartup(MAKEWORD(2,2), &WsaData) != 0)<br />
Debug("Winsock Statup Error\n");<br />
<br />
SOCKET ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br />
if(ListenSocket == INVALID_SOCKET)<br />
Debug("Socket Creation Error\n");<br />
<br />
struct sockaddr_in ServerAddress, ClientAddress;<br />
ServerAddress.sin_family = AF_INET;<br />
ServerAddress.sin_addr.s_addr = htonl(INADDR_ANY);<br />
ServerAddress.sin_port = htons(6969);<br />
<br />
if(bind(ListenSocket, (struct sockaddr *) &ServerAddress, sizeof(ServerAddress)) == SOCKET_ERROR)<br />
Debug("Socket Binding Error\n");<br />
<br />
if(Listen(ListenSocket, 5) == SOCKET_ERROR)<br />
Debug("Socket Listening Error\n");<br />
<br />
char xrec[2049];<br />
memset(xrec, 0x0, 2049);<br />
<br />
while(true)<br />
{<br />
int ClientAddressLength = sizeof(ClientAddress);<br />
<br />
SOCKET ClientSocket = accept(ListenSocket, (struct sockaddr *) &ClientAddress, &ClientAddressLength);<br />
if(ClientSocket == INVALID_SOCKET)<br />
Debug("Socket Accepting Error");<br />
<br />
while(recv(ClientSocket, xrec, 2048, 0) > 0)<br />
{<br />
<br />
FILE *fp;<br />
fp = fopen("C:\\TestFile.dat", "ab");<br />
fprintf(fp, xrec);<br />
fclose(fp);<br />
<br />
memset(xrec, 0x0, 1025);<br />
}<br />
}<br />
}<br />
Here is the c# code:
<br />
public void SendFile()<br />
{<br />
Socket so = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<br />
IPHostEntry localHostEntry = Dns.GetHostByName(Dns.GetHostName());<br />
IPEndPoint localIpEndPoint = new IPEndPoint(localHostEntry.AddressList[0], 0);<br />
so.Bind(localIpEndPoint);<br />
<br />
IPHostEntry remoteHostEntry = Dns.GetHostByName("192.168.1.49");<br />
IPEndPoint remoteIpEndPoint = new IPEndPoint(remoteHostEntry.AddressList[0], 6969);<br />
so.Connect(remoteIpEndPoint);<br />
<br />
BinaryReader br = new BinaryReader(new FileStream("D:\\thefile.dat", FileMode.Open, FileAccess.Read, FileShare.None));<br />
<br />
for(int x = 0; x < br.BaseStream.Length / 2048; x++)<br />
{<br />
Byte[] BytesToSend = br.ReadBytes(2048);<br />
so.Send(BytesToSend);<br />
}<br />
<br />
br.Close();<br />
so.Close();<br />
}<br />
Thanks!!!
|
|
|
|
|
farklem@gmail.com wrote:
the application tends to crash
"Tends to crash" is a bit vague What's the error exactly? An exception? What exception? Where?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I get the error: "Access violation reading location 0xcccccccc"
Its really not the error that bothers me but the time it takes to transfer such a small amount. I don't know of a proper way to write this code because I haven't found any good examples of something like this.
|
|
|
|