snoopy11's Profile User Rating: *****

Reputation: 982 Master
Active Posts:
3,014 (1.49 per day)
20-March 10
Profile Views:
Last Active:
User is offline Yesterday, 03:40 AM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Dream Kudos:
Expert In:
Icon   snoopy11 has not set their status

Posts I've Made

  1. In Topic: VOTING - Signature of the month: September 2015

    Posted 2 Oct 2015

    I voted for Xupicor too.... but because I like the idea of the story behind how Mars came to be a desert planet.

  2. In Topic: print the lowest and highest digit in the number.

    Posted 2 Oct 2015

    I was thinking the exact same thing when I put the code tags in.

    Well done for saying it though !
  3. In Topic: Needed suggestions on BookMark application in C++?

    Posted 2 Oct 2015

    View PostSkydiver, on 01 October 2015 - 01:48 PM, said:

    That's like me saying that I'm making a nuclear bomb as my winter garage project, but could somebody please guide me on how to create one because I don't know the first thing about how to do it.

    A nuclear bomb you say...?

    That's a very strange choice.

    I wonder what your Advanced Insights Profile would say about you ?


    Especially your Values Index ?

  4. In Topic: C++ Win32 FPS and DeltaTime Implementation

    Posted 30 Sep 2015


    Your updated code is still a bit of a mess isn't it ?

    As you say there are some problems with it.

    1. The fps is incredibly high as if it is calculated wrong.

    This has more to do with local variables and you are resetting them to zero every time the function is called putting static in front of everything won't solve this moving them into the class definition and setting them to zero in the constructor will solve your problems.

    2. The program is taking a while to load..

    Yes, you don't say, this is because you dont really understand to a level that you should before writing window classes how win32 programs work.

    3. The program wont close.

    Again this is a mixture of not understanding how win32 programs work and not understanding how windows classes operate.

    Overall it looks like you cobbled together some code you found online and threw it at the computer screen and hoped it would stick. Well it didn't it fell apart.

    Get a good book on win32 programming.

    Here is your fixed code.

    Now as a disclaimer I would never write code like this but this is my interpretation on how to fix your code as it currently stands.

    #include "Basewindow.h"
    #include "Childwindow.h"
    int APIENTRY WinMain(HINSTANCE h_instance, HINSTANCE h_prev_instance, LPSTR lp_cmd_line, int n_cmd_show) {
    	ChildWindow child_window(h_instance, TEXT("Child Window"));
    	BaseWindow base_window(TEXT("Base Window"), child_window.ClassName());
    	bool exitprogram = true;
    	while (exitprogram !=false)
    		exitprogram = base_window.MessagePoll();
    	return 0;


    #ifndef __BASEWINDOW_H__
    #define __BASEWINDOW_H__
    #pragma once
    #include <sstream>
    #include "Abstractwindow.h"
    #include "Childwindow.h"
    #include <cmath>
    class BaseWindow : public AbstractWindow {
    #pragma region Test Methods
    	void Update();
    	void Render();
    #pragma endregion
    #pragma region Methods
    	bool MessagePoll();
    	void CalculateFPS();
    	BaseWindow(const TCHAR*, const TCHAR*);
    	void Show();
    	virtual LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
    #pragma region Handles
    	bool CreateBackBuffer(HWND);
    	bool OnPaint(HWND);
    #pragma endregion
    #pragma endregion
    #pragma region Variables
    	bool paint_;
    	bool is_running = true;
    	int fps_;
    	int rectX;
    	int rectY;
    	int direction;
    	RECT window_rect_;				// Structure for window width and height
    	int client_width_;
    	int client_height_;
    	POINT mouse_pos_;
    	float delta_time;
    	int frame_count;
    	float elapsed_time;
    	__int64 prev_time;
    	__int64 current_time;
    	__int64 counts_per_sec;
    #pragma region Back Buffer
    	HDC hdc_;					// Handle to Device Context
    	HDC back_buffer_;			// Back Buffer
    	HBITMAP bitmap_;           // Current bitmap
    #pragma endregion
    #pragma endregion
    #endif // !__BASEWINDOW_H__


    #include "Basewindow.h"
    BaseWindow::BaseWindow() {}
    BaseWindow::~BaseWindow() {}
    BaseWindow::BaseWindow(const TCHAR* window_name, const TCHAR* class_name) {
    	style_ex_ = NULL;
    	class_name_ = class_name;
    	window_name_ = window_name;
    	x_ = CW_USEDEFAULT;
    	width_ = CW_USEDEFAULT;
    	height_ = CW_USEDEFAULT;
    	parent_ = NULL;
    	menu_ = NULL;
    	instance_ = GetModuleHandle(NULL);
    	paint_ = false;
    	rectX = 100;
    	rectY = 100;
    	delta_time = 0.0f;
    	elapsed_time = 0.0f;
    	frame_count = 0;
    	prev_time = 0;
    	current_time = 0;
    	__int64 counts_per_sec;
    void BaseWindow::Show() {
    	ShowWindow(hwnd_, SW_SHOW);
    LRESULT CALLBACK BaseWindow::WindowProcedure(HWND hwnd, UINT message, WPARAM w_param, LPARAM l_param) {
    	switch (message) {
    	case WM_CREATE:
    		// MessageBox(hwnd, "TEXT", "caption", MB_OK);
    		 return 0;
    	case WM_PAINT:
    		if (paint_) {
    			paint_ = false;
    		return 0;
    	case WM_CLOSE:
    		is_running = false;
    		return 0;
    		return DefWindowProc(hwnd, message, w_param, l_param);
    bool BaseWindow::MessagePoll() {
    	// Counts Per Second
    	// Seconds Per Count
    	float sec_per_count = 1.0f / counts_per_sec;
    	// Pervious Time
    	MSG message = {};
    	PeekMessage(&message,hwnd_, 0, 0,PM_REMOVE);
    			// Get current count
    			// DeltaTime
    			delta_time = (current_time - prev_time) * sec_per_count;
    			elapsed_time += delta_time;
    			// Render
    			if (delta_time > 0.00002f)
    				paint_ = true;
    				InvalidateRect(hwnd_, NULL, false);
    			prev_time = current_time;
    		return is_running;
    void BaseWindow::CalculateFPS() {
    	// Frams Per Second
    	if (elapsed_time >= 1.0f) {
    		fps_ = frame_count;
    		// Output to Window Title
    		std::stringstream ss;
    		ss << window_name_ << " FPS " << fps_;
    		SetWindowText(hwnd_, ss.str().c_str());
    		frame_count = 0;
    		elapsed_time = 0.0f;
    #pragma region Handles
    bool BaseWindow::CreateBackBuffer(HWND hwnd) {
    	GetClientRect(hwnd, &window_rect_);
    	client_width_ = window_rect_.right;
    	client_height_ = window_rect_.bottom;
    	hdc_ = GetDC(hwnd);	// Get the Device Context
    	back_buffer_ = CreateCompatibleDC(hdc_);	// Create Back Buffer
    	bitmap_ = CreateCompatibleBitmap(hdc_,client_width_, client_height_);
    	SelectObject(back_buffer_, bitmap_);	// Select Bitmap
    	return true;
    bool BaseWindow::OnPaint(HWND hwnd) {
    	PAINTSTRUCT paintstruct;
    	hdc_ = BeginPaint(hwnd_, &paintstruct);		// Get the Device Context
    	// Paint
    	BitBlt(hdc_, 0, 0,client_width_,client_height_,back_buffer_,0,0,SRCCOPY);		// Display the back buff
    	EndPaint(hwnd, &paintstruct);
    	return true;
    void BaseWindow::Update()
    	if (direction == 1)
    		rectX = rectX-1;
    		if (rectX < 100)
    		{direction = 0;}
    		rectX = rectX + 1;
    	if (rectX > 300)
    		direction = 1;
    void BaseWindow::Render() {
    	BitBlt(back_buffer_, 0, 0, client_width_, client_height_, NULL, NULL, NULL, WHITENESS);
    	HBRUSH brush = (HBRUSH)(CreateSolidBrush(RGB(255,0,0)));
    	SelectObject(back_buffer_, brush);		// Select Brush
    	Rectangle(back_buffer_, rectX, rectY, rectX+100,rectY+100);
    #pragma endregion

    As you can now see animating something in gdi is not great its a bit slow in the rendering.

    But as it stands its the best I can do with the way you have designed the classes and the rest of the program like the unnecessary functions that are only used once etc...

    You are very lucky I was bored !

  5. In Topic: VOTING - Signature of the month: September 2015

    Posted 30 Sep 2015

    Well just to clarify what shiny user bar BetaWar is talking about,

    it's this one........

    Posted Image

My Information

Member Title:
Engineering ● Software
Age Unknown
Birthday Unknown
Years Programming:
Programming Languages:
C/C++, Java, Python, J2ME, Android, Liberty Basic, Basic.
learning and C#

Contact Information



  • (2 Pages)
  • +
  • 1
  • 2
  1. Photo

    moonlight1020 Icon

    07 Jul 2015 - 05:36
  2. Photo

    moonlight1020 Icon

    06 Jul 2015 - 15:36
  3. Photo

    Icebreake Icon

    13 Apr 2015 - 10:36
    Hi can you help me with a sound recorder?
  4. Photo

    da1 Icon

    16 Jun 2014 - 22:25
    can you help me not sure what this other guy is telling me
  5. Photo

    David W Icon

    15 Jun 2014 - 04:54
    Hey snoop's ... good to see you're still breathing :)
    Shalom my friend ... and best regards David
  6. Photo

    tarmizi_adam2005 Icon

    27 Nov 2013 - 18:59
    Just wanted to stop by and say thanks for giving some nice advice in my post (reading wave file c/c++) the other day. Thank you so much snoopy11 !
  7. Photo

    yowzz28 Icon

    07 Oct 2013 - 23:44
    hello sir can you please help me to my project in turbo c++ IDE We will do a simple payroll system just a simple only sir . Please help me :((
  8. Photo

    ankush.dev2 Icon

    02 Aug 2013 - 11:27
    sir what can i do to enhance my knowledge of c/c++ programming..??
    i am the one you helped me last day regarding that audio library proect...
  9. Photo

    cpp_help Icon

    31 Jul 2013 - 20:18
    Hello Snoopy11. I often use this site to learn more about c++ and I have seen many of your comments in helping other people. You seem quite knowledgeable in c++. I needed some help. Can you email me at please. I would really appreciate it. Thanks.
  10. Photo

    lana ana Icon

    29 Apr 2013 - 00:25
    this is my page on fb ,, please if u can help me
  11. Photo

    lana ana Icon

    29 Apr 2013 - 00:24
    hello ... i am lana from jordan can u help me in problem please i must send it to my Dr today please i need ur help ,,, ??
    my problem about multithread
  12. Photo

    mamelove25 Icon

    19 Feb 2013 - 11:02
    Hello My Dear, My Name is Mame. i saw your profile today and became interested in you,i will also like to know you more,and if you can send an email to my email address,i will give you my pictures here is my email address ( I believe we can move from here! Am waiting for your mail to my email address above because i have much to tell you,
    love Miss Mame.
  13. Photo

    raghav.naganathan Icon

    16 Nov 2012 - 02:21
    Dude...before your rep(343) changes, I would like to tell you that it is a perfect cube :)
  14. Photo

    SaranyaNair Icon

    02 Oct 2012 - 22:51
    hi snoopy..i'm new to programming,,can u guide me some step how to more explore in programming?
  15. Photo

    Joshuwa Icon

    07 Jun 2012 - 17:42
    I am new to programming and I really want to learn. What would you suggest learning first? Whats the best approach?
  • (2 Pages)
  • +
  • 1
  • 2