|
Ah - what I do is I declare it in one header file, eg:
LPTSTR szWindowName = "My Program"
and then when ever I want to use it, I just include the header file and use it like this:
SetWindowText(hWnd, szWindowName);
It this the wrong way to do it?
Also, I have spotted that there in the stdafx.h header file, all of the variables are declared within a
#if !defined(STDAFX...)
#define STDAFX
#include <windows.h>
#endif
Could this be relevant to my problem?
Thankyou,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
OK, there's the problem, you're defining szWindowName in one header file, but then including that header file in multiple CPP files. The result: szWindowName ends up being defined in all those CPP files and your linker gets upset.
You have two options:
1. If szWindowName is never going to change, you can just make it constant:
const LPCTSTR szWindowName = "My Program";
If you do this, then I recommend changing the name to something like WINDOW_NAME to make it obvious it's constant.
2. If szWindowName will change, then you need to make it work like a global variable, which I explained in the previous post. Then I recommend calling it g_szWindowName to make it obvious that its global.
Regards,
Alvaro
|
|
|
|
|
I need some help with this one pleaseee
"write a windows program that looks like a digital clock".
two parts:
first part: to built a simple windows program that does nothing but start a framwork from running.
second part: the way i envisage a clock functioning is that its updating should be essentially a backround process. The calculation of the system's time should occure say every 5 seconds. Then you format a string that will contain an updated time value, post it off for display, and put your program thread back to sleep. That leaves the program able to let other internal threads run.
|
|
|
|
|
Seems like homework, so I well let you work out the details.
The best way to approach this problem is not with threads, which add innecesary complexity, but rather with windows timers (see SetTimer() ). These timers can perform the task for which you proposed a background thread, namely get a message posted to your main thread periodically.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
I got a request to make a program that seamlessly writes out some generic info on the background on a Windows 2000 (or higher) machine. (info is such as quote of the hour, fre RAM, incoming mails, current song in Winamp, whaterver info that can be summarized in short strings, you get the idea)
Well, such a program needs a few properties: Transparancy, Not able to be activated, not show up in the taskbar. More ofcourse, but for now these are the important ones.
Trancaparency is easely fixed, just a layered window WS_EX_LAYERED with a call to the SetLayeredWindowAttributes function and selecting a COLORREF color to be treated as transparent.
Also giving it the WS_EX_NOACTIVATE style unables the windows to be in the foreground. And making it not able to show up in the taskbar, well, a toolbar have that property, so giving it the
WS_EX_TOOLWINDOW style solves that problem.
Now the part that I cannot solve remains, how to make the border, and most importantly, the titlebar to dissapear? (no x-shutdown icon isn't a problem, just use the commandline and send a shutdown mesage or something)
But for it to fit nicely onto the desktop background I need to remove the titlebar and border. Anyone who knows ?
// Christoffer Sandberg , christoffer_sandberg@hotmail
|
|
|
|
|
Well, if you are using the dialog editor from vc++, just change the border style to 'none' using the dialog properties 'styles' tab.... or with c++ code, call the ModifyStyle(WS_OVERLAPPEDWINDOW, 0, SWP_FRAMECHANGED) of your window class, and you have a window without any frame!
----
Rui Lopes
|
|
|
|
|
Ahh, that is indeed a neat function, unfortenatly is is a member of the CWindow class (ATL) or the CWnd (MFC)(atleast what I was able to figure out). What I have is a standard Win32 program (none ATL, none MFC) application, so I use the RegisterClassEx and CreateWindowEx functions in the API to do my work, so all I have access to is the hInstance and hWnd of the program/window. Is there anyway to go from there and still being able to remove the the WS_OVERLAPPEDWINDOW style?
|
|
|
|
|
Well, the ModifyStyle is a straitforward function to implement.
Use this code instead of the ModifyWindow,
<br />
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE)&~WS_OVERLAPPEDWINDOW);<br />
<br />
::SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED);<br />
But since you are using the CreateWindowEx, you can create the window without the WS_OVERLAPPEDWINDOW style, so there is no need for this code....
----
Rui Lopes
|
|
|
|
|
How does one pass the parent dialog box's handle to the contructor of a child dialog box that it creates?
I need to access the public methods of the parent dialog box from the child dialog box.
Thanks.
|
|
|
|
|
When you create the child dialog, pass the pointer of the parent dialog For example, call this from a parent dialog
void CParentDlg::SomeFunc()
{
CChildDlg dlg(this);
dlg.DoModal();
.
.
}
Now call GetParent() to access the parent dialog
CParentDlg* pParentWnd = (CParentDlg*)GetParent(); Now use pParentWnd to access the public functions from child dialog
Hope this helps
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
|
Hello, the codegurus around the world.;)
GetParent() is one way, but not so much technically.
So, pass the handle of parent of the constructor.
CChildDlg dlg (this);
dlg.DoModal();
And the constructor of CChildDlg;
ChildDlg::ChildDlg (CWnd* pWnd)
{
ASSERT(pWnd);
m_pParent = pWnd;
}
Good Luck!
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
- Are there any Linux disscussion boards?
- Please tell me the URL.
- Regards,
Maer
|
|
|
|
|
billions of them. Thats the big thing with Linux, the information you need is spread across a million sites and in an order that the best search engines in the world can't manage.
I'm not anti-linux at all, I use it at home and at work, but I sometimes wish a proper professional company would get hold of it and sort it out a bit.
Before any Linux gurus write in to give me a hammering, I've been a unix man since 1979 (developer), and linux since it was born, my argument is not with the product but with the the well just about everything else about it.
There, I've said my piece.
http://www.mandrakesoft.com leads to some discussion groups and tutorials, there are some very good programming tutorials too.
Also, don't forget news groups, there's about 20 billion billion of those. I lie not. Not often anyway.
We do it for the joy of seeing the users struggle.
|
|
|
|
|
Rassman wrote:
I sometimes wish a proper professional company would get hold of it and sort it out a bit.
Yeah, wouldn't it be great if somebody like IBM got involved in developing Linux...
|
|
|
|
|
Personally I'd rather see a Microsoft Linux. The only way we'll get any decent tools and resources that do things that we want them to do and not what some lame brained hacker thinks is a cool idea
Michael
|
|
|
|
|
Dead right there. A typical example was a Developer tool which was close to being like MS developers programming environment, when you first look its brilliant then you find the other half of it, the part that makes it useable, costs two arms one leg and a bag of marbles.
I am used to programming in vi editors, and having other windows open for make etc, but it would be so nice if I could do it all in one place.
But, in linux's favour I would say that, as with unix, its a very uncluttered environment. Mainly because it doesn't have to come out of the box ready to work in all environments in as automated a way as possible. So, if you do have a mojor number crunching maths modeling job to do, a Linux is great for that. Add Samba and you have an effective NT server so its easy to feed it data, let it chew it a while, then pick up the results.
We do it for the joy of seeing the users struggle.
|
|
|
|
|
I totally agree. Microsoft makes very little money off the OS as compared to their other projects, particularly office. I think the antitrust trial should relegate them to no longer having their own OS, and everyone just uses the Linux kernel. It would help Microsoft sell stuff for other platforms, thus increasing their market, while not allowing them to leverage their monopolistic powers. I think it's a win for everyone...
But Microsoft is doing some work on FreeBSD (Rotor project: C# to another platform) FreeBSD is also not seen as a cancer because it doesn't use the GPL.
|
|
|
|
|
Linux experts are old-fashioned, we prefer mailing lists and newsgroups to WWW discussion boards. If you have already chosen a particular Linux distribution, see the distribution's home page for links to resources.
|
|
|
|
|
try linuxdoc.org - not a discussion board but full of information.
What do you need help with?
|
|
|
|
|
- Thanks pal!
- The web site "www.linuxdoc.org" is excellent!
- Are there any disscussion boards that I can use?
-Regards,
Maer
|
|
|
|
|
I've tried to register an OCX using regsrv32, but my program still won't show the control as it keep saying "An unsupported operations was attempted"
I'm using Microsoft FlexGrid 6.0 control in my program
.. anyone help meee
|
|
|
|
|
Hi all,
Currently I'm working on a program with (at this moment) 100 windows.
In the app of the program I have this code - (x 100).
m_pProg001Template = new CMultiDocTemplate(
IDR_MENU,
RUNTIME_CLASS(CDProg001Doc),
RUNTIME_CLASS(CDProg001Frame),
RUNTIME_CLASS(CDProg001View));
AddDocTemplate(m_pProg001Template);
m_pProg002Template = new CMultiDocTemplate(
IDR_MENU,
RUNTIME_CLASS(CDProg002Doc),
RUNTIME_CLASS(CDProg002Frame),
RUNTIME_CLASS(CDProg002View));
AddDocTemplate(m_pProg002Template);
etc, etc..
then ..
OnCommand (ID_MENU_001, OnProg001)
OnCommand (ID_MENU_002, OnProg002)
(x 100) etc, etc..
App::OnProg001() (x 100)
{
m_pProg001Template->OpenDocumentFile(NULL, TRUE);
}
etc, etc ..
This doesn't look good, and gives a lot of code in the app.
I have the feeling that there is a easier way to do this,
maybe with 5 lines of code , but I have no idea how to do this.
Anybody??
Greetings
Rene
|
|
|
|
|
I never criticise another persons code, afteral. Displaying your code is a bit like displaying your underpants, you never really know if there's a skid mark showing.
But, 100 windows in one application?, Lets just say it seemed a good idea at the time and tell the project leader it was only done to test the theory before going on to the release version, ok?
If you still want 100 windows, you could have an array of doctemplates,
CString sClasssName;
for( j=0;j<100;j++)
{
sClassName = ArrayofClassNames[j];
m_pArrayofTemplates[j] = new CMultiDocTemplate( IDR_MENU, RUNTIME_CLASS(sClassName), RUNTIME_CLASS(CDProg002Frame), RUNTIME_CLASS(sClassName)); AddDocTemplate(m_pProg002Template);
}
I'm sure you get the gist (sorry have to rush this my German server has just gone awal).
But, are you sure you need 100 windows? do you actually need 100 ActiveX windows displaying various information (whatever your app is) which you can create/show/hide/ etc as needed.
sh*t sh*t even i can't get in my german server. better go sort it.
We do it for the joy of seeing the users struggle.
|
|
|
|
|