|
are you using visual Studio.net cause i am and i don't see a settings and when i press (Alt-F7), it does nothing. also when i am in the property pages dialog all i see is a bunch of folders, one of which is called linker... so i open that and i see these options..
-additional dependencies
-ignore all default libraries
-ignore specific library
-module definition file
-add module to assembly
-embed managed resource file
-force symbol references
-delay loaded dlls
i have tried putting this line in all of the above
C:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\lib
with no luck!
am i in the right dialog... is that right way to do it??
also when i used that #pragma, it didn't help i am still receiving this error.
Fatal Error C1010 unexpected end of file while looking for precompiled header directive
<snippet>
#include <winsock2.h>
#include <stdio.h>
#pragma comment(lib, "ws2_32.lib")
void main(int argc, char **argv)
{
WSADATA wsaData;
SOCKET s;
SOCKADDR_IN ServerAddr;
int Port = 5150;
int Ret;
xai
|
|
|
|
|
xai wrote:
Fatal Error C1010 unexpected end of file while looking for precompiled header directive
Did you #include "stdafx.h"?
Alt-F7 is for VC6, sorry about that. But VC7 should have something similar.
xai wrote:
so i open that and i see these options..
-additional dependencies
Should be the one. type "ws2_32.lib" (no quotes) in there and see what happens
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
pj, you rock! thanks! i can finally get back to the fun part.
xai
|
|
|
|
|
Hi all,
I have two question regarding win programming.
I have a simple application.
***********************
char str[10];
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_LBUTTONDOWN:
sprintf(str, "arg1 = %d, arg2 = %d" , argv[1], argv[2]);
MessageBox(NULL, "Hello", str, __FILE__, MB_OK);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(
0,
g_szClassName,
"theForger's Tutorial Application",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 480, 320,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
*****************************************
First question is:
How to give argv[1] argv[2] etc arguments to win app as one can give to console application.
What I want is when left button is clicked the argument given to the program should appear in a dialog box.
Better if you send me a simple code example.
My second question:
I am using Visual Studio C++ 6.0.
Say, the above app is Test.exe and I want to run this application a number of times with different arguments though Visual studio IDE and not through a batch file on dose command.
Now my question is, is there any way I can write a script in VS C++, like a bat file in dose and if so how?
Script file may look like:
Test.exe 2 3
Test.exe 4 5
Test.exe 6 7
Test.exe 8 9
Test.exe 10 11
............
...........
thanks in advance
regards
/rsasalm
|
|
|
|
|
Use the GetCommandLine() function to get your program's arguments. There are also __argc and __argv, which is a VC featue that the compiler sets up. You can use those variables just like argc/argv.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
1.) What is wrong with the LPSTR lpCmdLine parameter of the WinMain() function?
2.) - "Project" menu -> "Settings" (or Alt-F7)
- "Debug" tab
- "Program Arguements" edit box
- Enter what ever program arguments you want to pass to your program
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks PJ and others,
The solution suggested by PJ works if I run the program only once. What about if I want to run the program a number of times with different arguements, as I mentioned in my orginal mail.
I don't want to use bat file. What I need is a alternative way to bat file but through VC++ IDE. Is there any way to write bat file through VC++ IDE?
thanks again
regards
/rsasalm
|
|
|
|
|
A few months ago someone had a tricky resolution to enabling a button only if the CEdit had text in it. It was really elegant and succint, but I cant find it by doing a search of CP messages. Anyways, I cant test this out at the moment but wil this work?
void CAddKeyword::OnChangeEditaddnewkeyword()
{
CString tempNKW;
m_editAddNewKeyword.GetWindowText(tempNKW);
if(tempNKW != "")
m_editAddNewKeyword.EnableWindow(TRUE);
}
In onInitDialog I had done:
m_editAddNewKeyword.EnableWindow(FALSE);
Thanks,
ns
|
|
|
|
|
it will work!
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
If you also want the button to disable again when the edit gets empty (if the user for instance deletes what she previously entered) you've got to be slithgtly change your code:
void CAddKeyword::OnChangeEditaddnewkeyword()
{
CString tempNKW;
m_editAddNewKeyword.GetWindowText(tempNKW);
m_editAddNewKeyword.EnableWindow(tempNKW.IsEmpty()?FALSE:TRUE);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That was me!
And the solution was:
void CAddKeyword::OnChangeEditaddnewkeyword()
{
CString tempNKW;
m_editAddNewKeyword.GetWindowText(tempNKW);
m_editAddNewKeyword.EnableWindow(tempKNW.GetLength() > 0);
}
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Thanks so much! That was it!
|
|
|
|
|
I am checking a CString array to see if a word entered by the user exists in the array already. If it does, I want them to have a choice of entering a new word, or cancelling out. So far I have
CString newKW;
m_editAddNewKeyword.GetWindowText(newKW);
for( int i = 0; i<numFields, i++)
{
if( m_AddKWFldsHolder[i] == newKW)
{
int nRetMB = AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
m_editAddNewKeyword.SetWindowText("");
m_editAddNewKeyword.SetFocus();
but I am aware that this wont do because we want to restart the comparison all over, not from where it left off. I was playing with the MB_YESNO but that was even murkier for me. I'd appreciate any insights or suggestions,
Thanks,
ns
|
|
|
|
|
Code break, repost!
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
void CAddKeyword::OnSubmitkeyword()
{
m_editAddNewKeyword.GetWindowText(m_newKW);
if(m_newKW == "")m_editAddNewKeyword.SetFocus();
for( int i = 0; i (less than) numFields, i++)
{
if( m_AddKWFldsHolder[i] == m_newKW)
{
int nRetMB = AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
m_editAddNewKeyword.SetWindowText("");
m_editAddNewKeyword.SetFocus();
i = 0;
}
}
it didnt like the less than symbol here on CP
|
|
|
|
|
it didnt like the less than symbol here on CP
Replace your < characters with <
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I would recommend using a CMap - the searching will be faster. MFC has not a set class like STL, so you need to use something small like a bool as data:
CMap< CString, LPCSTR, bool, bool > map;
CString newKW = ...
bool dummy;
if(map.Lookup(newKW,dummy))
{
}
else
{
map.SetAt(newKW,dummy);
}
Pavel
Sonork 100.15206
|
|
|
|
|
MFC has not a set class like STL, so you need to use something small like a bool as data
Better yet, use STL's std::set and enter the wondrous STLland!
std::set<CString> s;
CString newKW = ...
if(s.find(newKW)!=s.end()){
}
else{
s.insert(newKW);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
StartSearch:
for( int i = 0; i)
{
if( m_AddKWFldsHolder[i] == newKW)
{
int nRetMB = AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
m_editAddNewKeyword.SetWindowText(""); m_editAddNewKeyword.SetFocus();
goto StartSearch;
Or for those who fear the goto.
BOOL bSearching = TRUE;
while (bSearching)
for( int i = 0; i)
{
if( m_AddKWFldsHolder[i] == newKW)
{
int nRetMB = AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
m_editAddNewKeyword.SetWindowText("");
m_editAddNewKeyword.SetFocus();
bSearching=TRUE;
break;
}
}
bSearching = FALSE;
}
|
|
|
|
|
Ok, simple question. I have a worker thread that I want to change the cursor to an hourglass when it starts, and then back when it's done. I've tried the seemingly innocous:
SetCursor(LoadCursor(NULL, IDC_WAIT));
but alas, no cursor change! The NULL is in place of an HINSTANCE
As with most seemingly simple things, I missed the mark! Any help is always a pleasure
thx!
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
put AfxGetInstanceHandle() to get a HINSTANCE
WUSIWUG
|
|
|
|
|
Ok. Now I have:
SetCursor(LoadCursor(AfxGetInstanceHandle(),IDC_WAIT));
I also tried:
SetCursor(LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_WAIT)));
And yet no cursor change
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
to really change the cursor you should handle the OnSetCursor function (WM_SETCURSOR, i think).
BOOL CISSimpleViewerDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (pWnd==(CWnd *)this)
{
if (nHitTest==HTCLIENT)
{
if ((message==WM_MOUSEMOVE) || (message==WM_LBUTTONDOWN) || (message==WM_LBUTTONUP))
{
SetCursor(AfxGetApp()->LoadCursor(IDC_OPENHAND));
return TRUE;
}
}
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
SetCursor() is not persistent, the new cursor only lasts until the next time your window gets a WM_SETCURSOR message, which is sent every time the mouse moves in your window. If you don't handle that message, DefWindowProc() resets the cursor to the arrow.
Since you're using MFC, just use CWaitCursor .
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|