|
I've created a dialog application in MSVC++ on an NT platform. Within the application I'm making periodic system calls to invoke the execution of a bat file. Every time the system call is made a MS Dos Command prompt window displaying cmd.exe in the title bar appears then disappears(quite annoying). Is there a way of disabling this behavior, or is there another call that can be made to invoke the bat file without the creation of the Dos window.
|
|
|
|
|
CreateProcess with CREATE_NO_WINDOW flag
|
|
|
|
|
One solution is SW_HIDE and CreateProcess().
STARTUPINFO si;
si.wShowWindow = SW_HIDE;
::CreateProcess(...);
Kuphryn
|
|
|
|
|
CreateProcess is the official way, but if you just need a quick alternative,
WinExec("whatever.exe", SW_HIDE);
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
i have made a little wrapper [in C#] for using windows hooks. When i came to test it, I found that it works on local hooks, butnot system wide hooks. i set the threadID to 0 as msdn instructs, but it doesnt work, so I was wondering if there are any special permissions needed to do such a thing. [i am using Windows Xp Pro]
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
|
Nishant S wrote:
Global hooks need to be in a DLL.
Well thats a bit stupid if you ask me. is that the SetWindowsHookEx call - or the callback in the dll?
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
|
Hy everyone!
I have a problem here...
my CRichEditCtrl, when it haves more than ~250 characteres, it crashes, and loses my CHARFORMAT atributes.
Or, if I try to make CString::GetLength() with the String that is associate with the control, it crashes too...
does anyone have some idea?
thanks!
Ricky
|
|
|
|
|
I need to know how I can detect whether the user currently has an active internet connection. Can anyone help? I've tried InetIsOffline(), but that only determines if the user is in online or offline mode, not if the actual connection is currently active.
|
|
|
|
|
One solution is to simply connect to a server.
Kuphryn
|
|
|
|
|
bool IsConnectedToInternet(void)
{
DEBUGF("IsConnectedToInternet");
WORD wVersionRequested = MAKEWORD(1, 1);
WSADATA wsaData;
TCHAR hostaname[1000];
int hostname_size = sizeof(hostaname);
bool connected = false;
if (WSAStartup(wVersionRequested, &wsaData) != 0)
{
DEBUGF("WSAStartup Failed (%i.%i) %s",
wsaData.wHighVersion, wsaData.wVersion, wsaData.szDescription);
return connected;
}
if (gethostname(hostaname, hostname_size) != SOCKET_ERROR)
{
struct hostent FAR *h = gethostbyname(hostaname);
if (h != NULL)
{
DEBUGF("gethostname %s %s", h->h_name, h->h_addr_list[0]);
if (strncmp(h->h_addr_list[0], "\x7f\x0\x0\0x1", 4)!=0)
{
connected = true;
}
}
}
else
{
DEBUGF("gethostname Failed");
}
WSACleanup();
return connected;
}
Todd Smith
|
|
|
|
|
Is it possible to add a scroll bar to a CStatic control?
I've derived a new base class from CStatic for graph/chart purposes, and I'd like to be able to allow the graph to scroll if it is too big for the available viewing area. I've found many graphing projects on the net, but none seem to have this feature which is of particular importance to me since I have long series of data.
I've tried adding the WS_HSCROLL and WS_VSCROLL styles, I've called EnableScrollBarCtrl(), and I've called ShowScrollBar() but none of these methods have any effect. Anyone know something I don't?
A second question: I've also added the SS_NOTIFY style, but my (base) class isn't receiving the notification. Do I have to override the message notification in every other class I derive from the base class to process the notification?
Thanks for the help,
--Dean
|
|
|
|
|
FWIW, I would have derived the control from CWnd, not CStatic. CStatic has too many restrictions such as the ones you described.
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!
|
|
|
|
|
Hello,
I have a listview that has LVS_ICON | LVS_ALIGNTOP | LVS_AUTOARRANGE style. I use ListView_InsertMarkHitTest do the hittest and ListView_SetInsertMark for the insert mark during drag-n-drop (DragOver). However, the insertion mark never display.
Do you have any idea?
Thanks,
Hiusing
|
|
|
|
|
Hi, all:
I am using VC6.0. I have a SDI application with Help system. All the toolbar buttons, menu items can get the context help, supported by the framework. I have three buttons on my CFormView window, I'd like to get context help on those three buttons when I use Context Help ( Arrow+question mark). What should I do to enable help on those three buttons?
I noticed that I have file called Resource.hm and it contains HIDC_MYBUTTON1,2,3. It is included in MyApplication.rc file. But I don't know how to get the context help on those.
Any help is highly appreciated.
Dion
Dion
|
|
|
|
|
http://www.codeproject.com/dialog/dlgboxtricks.asp[^]
A little over half way down the page. The method described works with dialogs, and should also work with form views.
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!
|
|
|
|
|
I have a class that is a data consumer with an identification number, when an object is instantiated a temporary ID is assigned to the object until it can dynamically aquire it's "real" number.
I have a CListCtrl that displays a list of these objects with their IDs as the label. As an object is created it needs to be displayed in this control so obviously the temporary ID is used until the real one comes along. The control is updated every second and when the new ID gets updated in the obj I need to be able to update the control to reflect this change without adding an additional line and leaving the old one hanging around. What I've done is, because the ojects are stored in a CMap, I store the key for each object in the ItemData of the list item. But when I go to pull the item data out, I don't always get the data I put in there. My code is below:
POSITION Pos = m_IndexToObjectMap.GetStartPosition();
long key = 0;
CString name = _T(" ");
CString id = _T(" ");
CDataClass Obj;
while(Pos != NULL){
bool bItemInList = false;
m_IndexToObjectMap.GetNextAssoc(Pos, key, Obj);
if(GetId(key) < 1)
continue;
id.Format("%.0f", GetId(key));
name = GetName(key);
for(int i = 0; i < m_List.GetItemCount(); i++){
if(key == (long)m_List.GetItemData(i)){
m_List.SetItemText(i, 0, id);
m_List.SetItemText(i, 1, name);
bItemInList = true;
break;
}
}
if(!bItemInList){
m_List.InsertItem(0, id);
m_List.SetItemText(0, 1, name);
m_List.SetItemData(0, (DWORD) key);
}
}
Any assistance is greatly appreciated,
John
|
|
|
|
|
Hi, i want to display a .jpg file in my SDI application. can anybody tell me how to do that? Just i could display .bmp files. Thank you in advance
|
|
|
|
|
Have a look at paintlib...It was very helpful when I was developing a PICT file decoder
http://www.paintlib.de/paintlib/
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
|
|
Since I am new to programming I am learning about my big mistakes gradually. My recent paranoia is memory leaks. When I declare local variables in Dialog Procedures or even WndProc (that go before WM_INITDIALOG and WM_CREATE) do they need to all be static so they don't get declared again. I don't quite understand how these functions work / get called. For example a dialog procedure gets called many times but does it end between those different calls or does the function get stuck in the message loop until the user terminates the dialog? Either am I be safe by using HWND hwnd, or int iNumber or do I specifically need to declare them as static? I learned Win32 from Petzol's book and I noticed he doesn't declare everything as static and I am quite confused as to which variables should be static and which not. Anyone have any advice for me?
|
|
|
|
|
( assuming it's in plain C )
variable declared on the stack (internally inside a function )( not thrue new/malloc ) will be freed when the function ends ( goes out of scope ).
if you need to have a variable that's shared between functions, you need to create a static variable in the implementation, if it's needed somewhere else, you need to put it in a header file.
Max.
|
|
|
|
|
georgiek50 wrote:
When I declare local variables in Dialog Procedures or even WndProc (that go before WM_INITDIALOG and WM_CREATE) do they need to all be static so they don't get declared again.
Only declare variables as static if you need to preserve their values between function calls. If the value is used temporarily inside the function, then just leave them as local (auto) variables.
georgiek50 wrote:
I don't quite understand how these functions work / get called. For example a dialog procedure gets called many times but does it end between those different calls or does the function get stuck in the message loop until the user terminates the dialog?
It gets called many times, or more accurately, every time a message is sent to your dialog box. It behaves just like any regular function call, the difference is that it's Windows that calls it for you.
georgiek50 wrote:
Either am I be safe by using HWND hwnd, or int iNumber or do I specifically need to declare them as static? I learned Win32 from Petzol's book and I noticed he doesn't declare everything as static and I am quite confused as to which variables should be static and which not. Anyone have any advice for me?
Again, just think of static variables as variables that are defined only once and then stay around forever, until the program ends. Compared to regular (local) variable, they offer no performance benefit. They actually cause your program to consume more memory since they don't go away until the program ends. Local variables are only loaded into memory when they're needed, such as when the function is called, and then their memory is automatically reclaimed.
Note that neither of these types of variables cause memory leaks. Those are caused by memory that's repeatedly allocated on the heap (with malloc), and never freed. This causes the program to eventually run out of space on the heap and crash.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|