|
I think you should override PreCreateWindow method, removing WS_VISIBLE flag (e.g. cs.style &= ~WS_VISIBLE ); however I didn't make a test.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks for your response. I added the following:
BOOL CdllMainCodeDlg::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~WS_VISIBLE;
return CDialog::PreCreateWindow(cs);
}
and I added the following to the h-file:
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
However, the CdllMainCodeDlg::PreCreateWindow is never executed, why is that? Do I need to add something to BEGIN_MESSAGE_MAP(CdllMainCodeDlg, CDialog) also?
|
|
|
|
|
Try to remove the WS_VISIBLE style in the dialog template inside resource (.rc ) file.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I don't think that would help. Because modal application dialogs can not be hidden. For that you've to go for modeless dialogs. I hope I'm right. I also had faced the same problem, and even tried all these steps. Didn't help me that.
- Malli...!
|
|
|
|
|
Malli_S wrote: For that you've to go for modeless dialogs .
Of course. The above was implicit.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Since I never call DoModal (I call Create instead) I think my dialog is not modal.
|
|
|
|
|
Thanks a lot, it works great now!
|
|
|
|
|
Try this :
put a member pointer variable of your dialog class into the application class (e.g. m_pApplicationWnd). And add following code to InitInstance() of the application class.
m_pApplicationWnd = new CYourDlg();<br />
m_pApplicationWnd->Create(IDD_DIALOG_ID);<br />
m_pMainWnd = m_pApplicationWnd;<br />
ShowWindow(m_pMainWnd->GetSafeHwnd(),SW_HIDE);<br />
return TRUE;
Be sure to delete the allocated object in ExitInstance() of the application class.
<br />
if(m_pApplicationWnd)<br />
{<br />
m_pApplicationWnd->DestroyWindow();<br />
delete m_pApplicationWnd;<br />
}<br />
<br />
This is to create modeless dialog, so that you can hide your application dialog !
- Malli...!
|
|
|
|
|
Thanks for your reply. CPallini's suggestion seems simpler and it seems to work just fine so I will use his suggestion instead.
|
|
|
|
|
Hi all,
I need to identify next available free port in a system and bind it to a socket.
I have done this on unix before but now have to do it on VC++ without MFCs. A tutorial directed me to do the following:
http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#windows
struct sockaddr_in my_socket_addr;
sockfd = socket(AF_INET,SOCK_STREAM,0);
my_socket_addr.sin_family = AF_INET; // host byte order
my_socket_addr.sin_addr.s_addr = htonl(INADDR_ANY); //automatically fill with server IP
my_socket_addr.sin_port = 0; // port wildcard
memset(my_socket_addr.sin_zero, '\0', sizeof my_socket_addr.sin_zero); // setting all to zero
if ( bind(sockfd, (struct sockaddr *)&my_socket_addr, sizeof(my_socket_addr)) < 0 )
{
cout<<" Error in Binding socket!!";
exit(1);
}
cout << "port = "<< ntohs(my_socket_addr.sin_port) << endl; // print port
Basically it says that by assigning sin_port=0 the bind function knows it must allocate dynamically.
But when i print the port number generated i get the portno assigned as 0. The allocation hasn't taken place.
What could be the reason?
I would appreciate if you could direct me to any other way of dynamically assigning port numbers in VC++.
Its quite urgent! need help please!
Thanks in advance
Shreyas
|
|
|
|
|
Shreyas Ganesh wrote: I have done this on unix before but now have to do it on VC++ without MFCs.
It is the same on Unix and Windows, you let the networking stack assign a free local port number. But there is an error in your code, you reset the structure after you assign it. Here is a fix:
<br />
SOCKADDR_IN mySockAddr;<br />
memset(&mySockAddr, 0, sizeof(mySockAddr));<br />
mySockAddr.sin_family = AF_INET;<br />
mySockAddr.sin_addr.s_addr = htonl(INADDR_ANY);<br />
mySockAddr.sin_port = 0;<br />
if(::bind(sockFd, (SOCKADDR*)&mySockAddr, sizeof(mySockAddr)) == SOCKET_ERROR) ...<br />
Hope that works for you.
|
|
|
|
|
TCHAR t;
const char *pc=cosnt char*(&t);
hi... i used this way.
but i didn't get the answer.
the error is "syntax error:'const'
what is wrong in above code?
my input is TCHAR[500];
i have to covert this in const char* format.
can anyone help me?
paulraj
|
|
|
|
|
TCHAR expands either to char (when _UNICODE is NOT defined) or to wchar_t (when _UNICODE IS defined) data type. Hence, if _UNICODE is not defined, you have already what you need. On the other hand, if _UNICODE is defined...uhm...dangers are beckoning on the horizon...
Usually you should continue with generic text mapping (TCHAR) and avoid explicit assignment to standard data types.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Firstly, "const" on the right hand is not needed.
And then, why not try WideCharToMultiByte()?
|
|
|
|
|
i jus wanted to know how do i show the values in the edit box when i use the timer. this value should get updated every second. till a range. for example till 100. in the edit box it should display from 1 to 100. actually i am using a for loop to iterate te value till 100. but only the last value is printing. i have set the timer lik this
OnButton Function:
&
<br />
SetTimer(1,100,NULL);<br />
<br />
and on the OnTimer function:P
<br />
CString str1;<br />
<br />
<br />
if (nIDEvent==1)<br />
{<br />
<br />
for(int i=0;i<=100;i++)<br />
{ <br />
<br />
str1.Format("%d",i);<br />
if(i%2==0)<br />
{<br />
m_listbox.AddString(str1);<br />
m_edit.SetWindowText(str1);<br />
}<br />
}<br />
<br />
}<br />
i know its a simple mistake. but i am not being able to figure out.
|
|
|
|
|
Read what the SetTimer() does. It sets up a timer in ms. And in the handler you run to 100
Greetings from Germany
|
|
|
|
|
might be the followig code work as u desire. Try it and let me know whether it worked or not. ( i know its in win32 and you are using MFC but i know u can make to use it )
#define ONE_SEC 1
int i=0;
case WM_INITDIALOG:
SetTimer(hdlg,ONE_SEC,10*100,NULL);
break;
case WM_TIMER:
if (wParam == ONE_SEC)
{
SetDlgItemInt(hdlg,IDC_EDIT1,i++,FALSE);
}
break;
|
|
|
|
|
You have not specified what is not working as expected, so please tell us what you want to do!
What do you need a timer for this?
|
|
|
|
|
i dont know if there is another way other than timer to increment the value in a edit box every sec or millisecond. the problem is it only shows the last number that is 100. i have to show it from 1 to 100.
|
|
|
|
|
ok, if I understand you correc, you want to increment the value of an edit box every 1 second, starting from 0 going to 100. If that is the case, then a timer is the way to go.
Your timer needs to be set up for 1000ms(1sec). You have set it up for 100ms only.
SetTimer(1,1000,NULL);
Now create a member variable for your edit control of type "value" and set its datatype to int. Lets call it "value".
In OnTimer:
if (nIDEvent==1)
{
if(value < 100)
{
value++;
UpdateData(FALSE);
}
}
|
|
|
|
|
|
Hello all,
i want to make a exe on a button click event. How to do this?? Is it possible to do it as we make a txt file using a object of CStdioFile. or i have to make two workspace in one project???
Thanks in advance
|
|
|
|
|
Do you want to make a exe file on your program or run an exe file when click a button.
|
|
|
|
|
I want to make a exe when i click a button on my already running exe.
|
|
|
|
|
You want to *make* an exe?
Are you writing a compiler?
Iain.
|
|
|
|