|
Is it bad? Not inherently. But that isn't the whole story.
In an application controlled 100% by you, then you can place your CoI/CoU in an OCX if you want to. As long as you follow the proper rules nobody cares.
But, if you aren't in control of the main application, then it is a VERY VERY bad idea to call CoI/CoU from any thread NOT MANAGED by you. If you create a thread, then feel free to call CoI/CoU in that thread all you want.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Again with the modeless....
I asked how to correct the layering of modeless windows and the "parent" CMainFrame application dialog. Thanks for answers, but...
NOW I have the question of multiple modeless dialogs and the same layering issues.
The focus changes ok between the modeless dialog and the CMainFrame dialog (the one with the menu/toolbars). The layering between (sub) modeless dialogs does not work as expected - the dialog with focus does not rise to top above other modeless dialogs
Help
Thanks.
|
|
|
|
|
Are you sure that all your modeless dialogs use the desktop as their parent window?
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
In order to get tabbing and focus changes to work correctly in this case, you need to set the 'Control' style in the modeless dialogs (the children), and the 'Control parent' style in the parent dialog.
We use this approach in a product where I work.
Gary R. Wheeler
|
|
|
|
|
I have a dialoge with this UI:
----------------------------------------
| My Dialoge |
----------------------------------------
| ---------- |
| |tree | Name: the name |
| |control |description:a description |
| | | |
| | | |
| | | |
| | | more stuff |
| | | |
| | | |
| | | |
| | | |
| ---------- |
----------------------------------------
The box on the left is a tree control.
The description can be a few words or an entire paragraph, forcing me to put more stuff many lines below the description. I was wondering it its possible to dynamically change the position of more stuff based on the number of lines that the description takes up...well im pretty sure that can be done but can you find out the number of lines that the description is taking up?
-Raffi
|
|
|
|
|
Have a look at the CDC::DrawText() function and the DT_CALCRECT flag
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
If a man is standing in the middle of the forest speaking and there is no woman around to hear him...is he still wrong?
|
|
|
|
|
thx for the help
-Raffi
|
|
|
|
|
Hi:
In a CFormView-derived view, I can change control colors by handling WM_CTLCOLOR messages.
What can I do to change control colors for a CView-derived view?
Thanks
|
|
|
|
|
Whether CFormView or CView derived does not matter, simply override OnCtlColor(...) [which is called when a WM_CTLCOLOR message arrives].
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Like Nish said, this is where you want to do it. You can use the nCtlColor variable to check for what kind of control it is and then send back a different HBRUSH for different controls to control the color.
|
|
|
|
|
Hi.
I am new to winsock program and has began study from Network Programming for Microsoft Windows, Second Edition by Anthony Jones and Jim Ohlund.
I am trying to get a code to basically resolve a hostname to its ip address. For example:
-----
user input: www.microsoft.com
app output: 207.46.230.220
-----
I am able to get the calculation above working using older winsock 1.1+ tool including the use of structure hostent, gethostbyname(), and inet_ntoa().
However, in their book, Jones and Ohlund recommend using the newer winsock tools including getaddrinfo() and getnameinfo(). I cannot figure out how to extract the corresponding IP address from a hostname. Here is the code:
-----
int rc = 0;
addrinfo hints, *result = NULL;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
if (getaddrinfo(rHName, "21", &hints, &result) != 0)
return false;
else
{
// This is where I need help getting the IP address
m_sIP = (reinterpret_cast<sockaddr *="">(result->ai_addr)->sa_data());// ->sa_data(); // inet_ntoa(*(reinterpret_cast<in_addr *="">(host->h_addr)));
return = true;
}
-----
In the code above, m_sIP is a character array. What do I have to cast result->ai_addr in order to access the IP address?
Thanks,
Kuphryn
|
|
|
|
|
Here is the solution to my original problem.
-----
{
m_bVeri = false;
addrinfo hints, *result = NULL;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_PASSIVE;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
if (getaddrinfo(static_cast<lpctstr>(rHName), m_sPort.c_str(), &hints, &result) != 0)
return m_bVeri;
if (getnameinfo(result->ai_addr, result->ai_addrlen, m_sIP, 256, NULL, 0, NI_NUMERICHOST) != 0)
return m_bVeri;
m_bVeri = true;
freeaddrinfo(result);
return m_bVeri;
}
Kuphryn
|
|
|
|
|
Hi,
It appears I ran into a bit of a contradiction.
According to the documentation for CInternetSession, you should be able to make your internet operations asynchronous and set up a callback to report on the status of the operations.
One of the requirements for this, is that:
In the CInternetSession constructor, dwFlags must include INTERNET_FLAG_ASYNC.
However, the first line of code in that constructor is:
ASSERT((dwFlags & INTERNET_FLAG_ASYNC) == 0);
My logical skills may be failing me, but that code tries to assert that dwFlags does NOT include INTERNET_FLAG_ASYNC, right?
So I have to set the flag, but I'm not allowed to set the flag. What's up with that? Or am I missing something?
All input appreciated,
Ren
|
|
|
|
|
I thought I had the answer for you because I have done a project that used CInternetSession for FTP and had to be asynchronous. After looking at that project it turns out that I used a thread. This would be a valid option for you if you can't find another way. If you decide to go with threads I can give you some sample code.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
I too ran into this problem earlier. Turned out the the docs on the MSDN CD are old/incorrect. See the latest online docs for CInternetSession .
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
It's alive! Beautiful, guys!
Finally some light at the end of the tunnel (no thanks to the msdn librarians. Oh, how they torture us...)
I wouldn't mind getting some threading sample code, though. It's not really an essential requirement of my project, but why aim for less than perfect?
Thanx a bunch,
Ren
renegade@killatactics.com
|
|
|
|
|
Using CPropertySheet, is there anyway to change the text of the Cancel button?
|
|
|
|
|
pSheet ->GetDlgItem (IDCANCEL) ->SetWindowText ("New Text");
That is assuming pSheet is a pointer to your sheet.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim,
I don't know how to do this with CPropertySheet. It gives you the 4 wizard buttons (Back, Next, Cancel, Help) automatically with member functions to manage them. See SetWizardButtons in MSDN. You don't have direct access to the buttons. I don't see a way to change the text on the Cancel Button.
Bob
|
|
|
|
|
Those buttons are just like any other button on a dialog. Get the window and then set the window text.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi,
I'm new to writing a service and I've found the following psuedo code for my main function:
for (int i = 1; i < argc; i++)
{
if ((argv[i][0] == TEXT('-')) || (argv[i][0] == TEXT('/')))
{
// Command line switch
if (lstrcmpi(&argv[i][1], TEXT("Service")) == 0)
InstallService();
if (lstrcmpi(&argv[i][1], TEXT("UnRegServer")) == 0)
RemoveService();
if (lstrcmpi(&argv[i][1], TEXT("debug")) == 0)
{
// Execute the service code
ServiceMain(0, NULL);
}
if (lstrcmpi(&argv[i][1], TEXT("service1")) == 0)
{
// Connect to the service control dispatcher
SERVICE_TABLE_ENTRY ServiceTable[] =
{
{ g_szServiceName, ServiceMain },
{ NULL, NULL } // End of list
};
chVERIFY(StartServiceCtrlDispatcher(ServiceTable));
}
}
}
From looking at this code, in order to install and start the service, I would have to call the application passing in -Service then -service1. Is there any way that I can just call -Service then make a call to net start service_name.exe?
Thanks for any help you can provide,
Craig
|
|
|
|
|
Here is what is going on...
When you type the command "XXXX -Service" the program is creating the entry in the service database for your service. One thing you don't see here is that when it creates the entry in the database it is specifying " -Service1" as the command line for the service.
THUS, when you start the service via the control panel or the net command, it is automatically run as "XXXX -Service1". Thus the program sees the "-Service1" parameter and knows that it is being run as a service and not interactively.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim,
Thanks for the reply, that seems to make sense but when I do the following at the command prompt this is what I get:
C:\Temp\MyService\Debug>MyService -Service
C:\Temp\MyService\Debug>net start MyService
The service is not responding to the control function.
More help is available by typing NET HELPMSG 2186.
I think this is happening because StartServiceCtrlDispatcher(...) isn't getting called because it never get's to:
if (lstrcmpi(&argv[i][1], TEXT("service1")) == 0)
{
// Connect to the service control dispatcher
SERVICE_TABLE_ENTRY ServiceTable[] =
{
{ g_szServiceName, ServiceMain },
{ NULL, NULL } // End of list
};
chVERIFY(StartServiceCtrlDispatcher(ServiceTable));
}
I'm not sure if this is actually the case but I think it is. Do you have any ideas about this?
Thanks,
Craig
|
|
|
|
|
If what I am thinking is correct, do this.
Run REGEDIT.
Locate the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YOUR_SERVICE_NAME
Under that key should be the command line used to start the service stored in the "ImagePath" value. Check to make sure that it looks something like:
"C:\DIR\DIR\DIR\YOUR_SERVICE_PROGRAM.EXE -service1"
If "-service1" is missing, then just as a test, add it to the end of that value. The try the NET START command again. If it works then, make sure that the code creating the service includes the "-service1" string.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim,
That is EXCELLENT, you've probably save me a couple days worth of work. Do you happen to know off the top of your head how I can change the default value of that registry setting inside the service? Or, do I have to just manually change that when I install the service?
Thanks again for all your help with this,
Craig
|
|
|
|
|